Skip to content

Commit

Permalink
Cleanup docker volumes after running updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurre Stender committed Sep 28, 2021
1 parent d553ef9 commit 02791b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/container-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}
Expand Down
19 changes: 17 additions & 2 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -165,4 +164,20 @@ export class Updater {
core.info(`Created ${updaterCommand} container: ${container.id}`)
return container
}

private async cleanup(proxy: Proxy): Promise<void> {
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})
}
}
}

0 comments on commit 02791b6

Please sign in to comment.