ci: deploy to container workflow - remove anonymous volumes on db delete

This commit is contained in:
NGPixel 2022-10-26 03:10:17 -04:00
parent db3c93a25a
commit 6503e57174
No known key found for this signature in database
GPG key ID: 8FDA2F1757F60D63

View file

@ -84,12 +84,16 @@ async function main () {
const containers = await dock.listContainers({ all: true })
for (const container of containers) {
if (container.Names.includes(`/dt-db-${branch}`) || container.Names.includes(`/dt-app-${branch}`)) {
const isDbContainer = container.Names.includes(`/dt-db-${branch}`)
console.info(`Terminating old container ${container.Id}...`)
const oldContainer = dock.getContainer(container.Id)
if (container.State === 'running') {
await oldContainer.stop({ t: 5 })
}
await oldContainer.remove({ force: true })
await oldContainer.remove({
force: true,
v: isDbContainer
})
}
}
console.info('Existing containers with same name have been terminated.')