Skip to content

Commit fa79939

Browse files
committed
chore: manage docker bloat on deployments
automatically prune old images and raise warnings for dangling volumes and exited containers on GitHub Actions workflow deployments. Closes #1918 Signed-off-by: Luiz Georg <luiz.georg@profusion.mobi>
1 parent 2069443 commit fa79939

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/deploy-production.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ jobs:
106106
cp ~/.env-production dashboard-production/.env &&
107107
cd dashboard-production &&
108108
git checkout ${GITHUB_SHA} &&
109-
docker compose -f docker-compose-next.yml pull &&
110-
docker compose -f docker-compose-next.yml up -d
109+
docker compose up --pull=always --remove-orphans --detach &&
110+
docker image prune -fa --filter "until=48h" &&
111+
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling" &&
112+
docker container ls -f status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
111113
"
112114
env:
113115
SSH_USER: ${{ secrets.STAGING_USER }}

.github/workflows/deploy-staging.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ jobs:
6767
cp ~/.env-staging dashboard-staging/.env &&
6868
cd dashboard-staging &&
6969
git checkout ${GITHUB_SHA} &&
70-
docker compose down &&
71-
docker compose build --no-cache &&
72-
docker compose up -d
70+
docker compose up --build --pull=always --remove-orphans --detach &&
71+
docker image prune -fa --filter "until=48h" &&
72+
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling" &&
73+
docker container ls -f status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
7374
"
7475
env:
7576
SSH_USER: ${{ secrets.STAGING_USER }}

.github/workflows/staging-db.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ jobs:
2424
git fetch
2525
git checkout ${{ github.event.inputs.GIT_BRANCH }}
2626
cd ..
27-
docker compose -f docker-compose-all.yaml --profile=self-hosted build
28-
docker compose -f docker-compose-all.yaml --profile=self-hosted up -d --remove-orphans
27+
docker compose -f docker-compose-all.yaml --profile=self-hosted up --build --pull=always --remove-orphans --detach
28+
docker image prune -fa --filter "until=48h"
29+
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling"
30+
docker container ls -f status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"

0 commit comments

Comments
 (0)