Merge pull request #519 from Dokploy/514-failing-to-refresh-docker-composeyml-from-github-repo

fix(compose): delete content when is remote server
This commit is contained in:
Mauricio Siu
2024-10-03 01:32:50 -06:00
committed by GitHub
4 changed files with 16 additions and 15 deletions

View File

@@ -147,15 +147,15 @@ export const cloneRawBitbucketRepositoryRemote = async (compose: Compose) => {
const bitbucketProvider = await findBitbucketById(bitbucketId); const bitbucketProvider = await findBitbucketById(bitbucketId);
const basePath = COMPOSE_PATH; const basePath = COMPOSE_PATH;
const outputPath = join(basePath, appName, "code"); const outputPath = join(basePath, appName, "code");
await recreateDirectory(outputPath);
const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`; const repoclone = `bitbucket.org/${bitbucketOwner}/${bitbucketRepository}.git`;
const cloneUrl = `https://${bitbucketProvider?.bitbucketUsername}:${bitbucketProvider?.appPassword}@${repoclone}`; const cloneUrl = `https://${bitbucketProvider?.bitbucketUsername}:${bitbucketProvider?.appPassword}@${repoclone}`;
try { try {
await execAsyncRemote( const command = `
serverId, rm -rf ${outputPath};
`git clone --branch ${bitbucketBranch} --depth 1 ${cloneUrl} ${outputPath}`, git clone --branch ${bitbucketBranch} --depth 1 ${cloneUrl} ${outputPath}
); `;
await execAsyncRemote(serverId, command);
} catch (error) { } catch (error) {
throw error; throw error;
} }

View File

@@ -271,13 +271,13 @@ export const cloneRawGithubRepositoryRemote = async (compose: Compose) => {
const octokit = authGithub(githubProvider); const octokit = authGithub(githubProvider);
const token = await getGithubToken(octokit); const token = await getGithubToken(octokit);
const repoclone = `github.com/${owner}/${repository}.git`; const repoclone = `github.com/${owner}/${repository}.git`;
await recreateDirectory(outputPath);
const cloneUrl = `https://oauth2:${token}@${repoclone}`; const cloneUrl = `https://oauth2:${token}@${repoclone}`;
try { try {
await execAsyncRemote( const command = `
serverId, rm -rf ${outputPath};
`git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}`, git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}
); `;
await execAsyncRemote(serverId, command);
} catch (error) { } catch (error) {
throw error; throw error;
} }

View File

@@ -390,14 +390,14 @@ export const cloneRawGitlabRepositoryRemote = async (compose: Compose) => {
await refreshGitlabToken(gitlabId); await refreshGitlabToken(gitlabId);
const basePath = COMPOSE_PATH; const basePath = COMPOSE_PATH;
const outputPath = join(basePath, appName, "code"); const outputPath = join(basePath, appName, "code");
await recreateDirectory(outputPath);
const repoclone = `gitlab.com/${gitlabPathNamespace}.git`; const repoclone = `gitlab.com/${gitlabPathNamespace}.git`;
const cloneUrl = `https://oauth2:${gitlabProvider?.accessToken}@${repoclone}`; const cloneUrl = `https://oauth2:${gitlabProvider?.accessToken}@${repoclone}`;
try { try {
await execAsyncRemote( const command = `
serverId, rm -rf ${outputPath};
`git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}`, git clone --branch ${branch} --depth 1 ${cloneUrl} ${outputPath}
); `;
await execAsyncRemote(serverId, command);
} catch (error) { } catch (error) {
throw error; throw error;
} }

View File

@@ -70,6 +70,7 @@ export const createComposeFileRawRemote = async (compose: Compose) => {
try { try {
const encodedContent = encodeBase64(composeFile); const encodedContent = encodeBase64(composeFile);
const command = ` const command = `
rm -rf ${outputPath};
mkdir -p ${outputPath}; mkdir -p ${outputPath};
echo "${encodedContent}" | base64 -d > "${filePath}"; echo "${encodedContent}" | base64 -d > "${filePath}";
`; `;