From 02791b62a0523433c86f87fb11f989521a0518dc Mon Sep 17 00:00:00 2001 From: Jurre Stender Date: Tue, 28 Sep 2021 17:28:09 +0200 Subject: [PATCH] Cleanup docker volumes after running updater --- src/container-service.ts | 2 +- src/updater.ts | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/container-service.ts b/src/container-service.ts index 9984e93..9432ff3 100644 --- a/src/container-service.ts +++ b/src/container-service.ts @@ -45,7 +45,7 @@ export const ContainerService = { await container.start() await container.wait() } finally { - await container.remove() + await container.remove({v: true}) core.info(`Cleaned up container ${container.id}`) } } diff --git a/src/updater.ts b/src/updater.ts index ebfcc04..1b93606 100644 --- a/src/updater.ts +++ b/src/updater.ts @@ -53,8 +53,7 @@ export class Updater { // TODO: report job runner_error? core.error(`Error ${e}`) } finally { - await proxy.shutdown() - await this.docker.pruneNetworks() + await this.cleanup(proxy) } } catch (e) { // TODO: report job runner_error? @@ -165,4 +164,20 @@ export class Updater { core.info(`Created ${updaterCommand} container: ${container.id}`) return container } + + private async cleanup(proxy: Proxy): Promise { + await proxy.shutdown() + await this.docker.pruneNetworks() + + const outputDir = path.join(__dirname, '../output') + const repoDir = path.join(__dirname, '../repo') + + if (fs.existsSync(outputDir)) { + fs.rmdirSync(outputDir, {recursive: true}) + } + + if (fs.existsSync(repoDir)) { + fs.rmdirSync(repoDir, {recursive: true}) + } + } }