Skip to content

Commit

Permalink
Merge pull request #519 from Dokploy/514-failing-to-refresh-docker-co…
Browse files Browse the repository at this point in the history
…mposeyml-from-github-repo

fix(compose): delete content when is remote server
  • Loading branch information
Siumauricio authored Oct 3, 2024
2 parents b5c0876 + a5eb4b0 commit 6a3ef5c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions apps/dokploy/server/utils/providers/bitbucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ export const cloneRawBitbucketRepositoryRemote = async (compose: Compose) => {
const bitbucketProvider = await findBitbucketById(bitbucketId);
const basePath = COMPOSE_PATH;
const outputPath = join(basePath, appName, "code");
await recreateDirectory(outputPath);
const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`;
const cloneUrl = `https://${bitbucketProvider?.bitbucketUsername}:${bitbucketProvider?.appPassword}@${repoclone}`;

try {
await execAsyncRemote(
serverId,
`git clone --branch ${bitbucketBranch} --depth 1 ${cloneUrl} ${outputPath}`,
);
const command = `
rm -rf ${outputPath};
git clone --branch ${bitbucketBranch} --depth 1 ${cloneUrl} ${outputPath}
`;
await execAsyncRemote(serverId, command);
} catch (error) {
throw error;
}
Expand Down
10 changes: 5 additions & 5 deletions apps/dokploy/server/utils/providers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ export const cloneRawGithubRepositoryRemote = async (compose: Compose) => {
const octokit = authGithub(githubProvider);
const token = await getGithubToken(octokit);
const repoclone = `github.com/${owner}/${repository}.git`;
await recreateDirectory(outputPath);
const cloneUrl = `https://oauth2:${token}@${repoclone}`;
try {
await execAsyncRemote(
serverId,
`git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}`,
);
const command = `
rm -rf ${outputPath};
git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}
`;
await execAsyncRemote(serverId, command);
} catch (error) {
throw error;
}
Expand Down
10 changes: 5 additions & 5 deletions apps/dokploy/server/utils/providers/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,14 @@ export const cloneRawGitlabRepositoryRemote = async (compose: Compose) => {
await refreshGitlabToken(gitlabId);
const basePath = COMPOSE_PATH;
const outputPath = join(basePath, appName, "code");
await recreateDirectory(outputPath);
const repoclone = `gitlab.com/${gitlabPathNamespace}.git`;
const cloneUrl = `https://oauth2:${gitlabProvider?.accessToken}@${repoclone}`;
try {
await execAsyncRemote(
serverId,
`git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}`,
);
const command = `
rm -rf ${outputPath};
git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}
`;
await execAsyncRemote(serverId, command);
} catch (error) {
throw error;
}
Expand Down
1 change: 1 addition & 0 deletions apps/dokploy/server/utils/providers/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const createComposeFileRawRemote = async (compose: Compose) => {
try {
const encodedContent = encodeBase64(composeFile);
const command = `
rm -rf ${outputPath};
mkdir -p ${outputPath};
echo "${encodedContent}" | base64 -d > "${filePath}";
`;
Expand Down

0 comments on commit 6a3ef5c

Please sign in to comment.