Skip to content

Commit

Permalink
feat: 최초 배포 시 컨테이너 정리 추가 및 불필요/필요 로직 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
flydog98 committed Dec 18, 2023
1 parent 9c34f7b commit e98aa44
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/backend/src/containers/containers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ContainersService {
private commandService: CommandService,
) {
if (this.configService.get<string>('SERVER_MODE') !== 'dev') {
this.commandService.executeCommand('docker rm -f $(docker ps -a -q)');
this.initializeContainers();
}
}
Expand Down Expand Up @@ -163,8 +164,6 @@ export class ContainersService {
const chownUpstreamCommand = `[ -d ~/upstreams/${quizId} ] && docker exec -u root ${containerId} chown -R ${user}:${user} /remote`;
const coreEditorCommand = `docker exec -w /home/quizzer/quiz/ -u ${user} ${containerId} git config --global core.editor /editor/output.sh`;
const mainBranchCommand = `docker exec -w /home/quizzer/quiz/ -u ${user} ${containerId} git config --global init.defaultbranch main`;
const containerDirectoryCommand = `mkdir /root/store/${containerId}`;
const containerDirectoryCpCommand = `docker cp ${containerId}:/home/quizzer/quiz/. /root/store/${containerId}/`;
await this.commandService.executeCommand(
createContainerCommand,
copyFilesCommand,
Expand All @@ -175,8 +174,6 @@ export class ContainersService {
chownUpstreamCommand,
coreEditorCommand,
mainBranchCommand,
containerDirectoryCommand,
containerDirectoryCpCommand,
);

return containerId;
Expand Down Expand Up @@ -204,9 +201,9 @@ export class ContainersService {
this.availableContainers.get(quizId).push(containerId);
});

// if (!(await this.isValidateContainerId(containerId))) {
// return await this.createContainer(quizId);
// }
if (!(await this.isValidateContainerId(containerId))) {
return await this.createContainer(quizId);
}

return containerId;
}
Expand Down

0 comments on commit e98aa44

Please sign in to comment.