Skip to content

Commit d88f321

Browse files
committed
fixup! chore: manage docker bloat on deployments
Signed-off-by: Luiz Georg <luiz.georg@profusion.mobi>
1 parent fa79939 commit d88f321

3 files changed

Lines changed: 54 additions & 10 deletions

File tree

.github/workflows/deploy-production.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,31 @@ jobs:
106106
cp ~/.env-production dashboard-production/.env &&
107107
cd dashboard-production &&
108108
git checkout ${GITHUB_SHA} &&
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}})"
109+
docker compose -f docker-compose-next.yml pull --policy=always &&
110+
docker compose -f docker-compose-next.yml up -d --remove-orphans
113111
"
114112
env:
115113
SSH_USER: ${{ secrets.STAGING_USER }}
116114
SSH_HOST: ${{ secrets.STAGING_HOST }}
117115
SSH_KEY: ${{ secrets.STAGING_KEY }}
118116

117+
- name: Prune docker artifacts on remote
118+
continue-on-error: true
119+
env:
120+
SSH_USER: ${{ secrets.STAGING_USER }}
121+
SSH_HOST: ${{ secrets.STAGING_HOST }}
122+
SSH_KEY: ${{ secrets.STAGING_KEY }}
123+
run: |
124+
eval $(ssh-agent -s)
125+
echo "$SSH_KEY" | ssh-add - >/dev/null
126+
ssh "${SSH_USER}@${SSH_HOST}" <<<'EOF'
127+
set -eu
128+
docker image prune -fa --filter "until=48h"
129+
docker builder prune -f --filter "until=48h"
130+
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling"
131+
docker container ls --filter status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
132+
EOF
133+
119134
- name: Discord notification on success
120135
if: success()
121136
env:

.github/workflows/deploy-staging.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,32 @@ jobs:
6767
cp ~/.env-staging dashboard-staging/.env &&
6868
cd dashboard-staging &&
6969
git checkout ${GITHUB_SHA} &&
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}})"
70+
docker compose pull --ignore-buildable --policy=always &&
71+
docker compose build --no-cache &&
72+
docker compose up -d --remove-orphans
7473
"
7574
env:
7675
SSH_USER: ${{ secrets.STAGING_USER }}
7776
SSH_HOST: ${{ secrets.STAGING_HOST }}
7877
SSH_KEY: ${{ secrets.STAGING_KEY }}
7978

79+
- name: Prune docker artifacts on remote
80+
continue-on-error: true
81+
env:
82+
SSH_USER: ${{ secrets.STAGING_USER }}
83+
SSH_HOST: ${{ secrets.STAGING_HOST }}
84+
SSH_KEY: ${{ secrets.STAGING_KEY }}
85+
run: |
86+
eval $(ssh-agent -s)
87+
echo "$SSH_KEY" | ssh-add - >/dev/null
88+
ssh "${SSH_USER}@${SSH_HOST}" <<<'EOF'
89+
set -eu
90+
docker image prune -fa --filter "until=48h"
91+
docker builder prune -f --filter "until=48h"
92+
docker volume ls --filter dangling=true --format "::warning::volume {{.Name}} is dangling"
93+
docker container ls --filter status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"
94+
EOF
95+
8096
e2e-tests:
8197
runs-on: ubuntu-latest
8298
timeout-minutes: 10

.github/workflows/staging-db.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ 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 up --build --pull=always --remove-orphans --detach
27+
docker compose -f docker-compose-all.yaml --profile=self-hosted pull --ignore-buildable
28+
docker compose -f docker-compose-all.yaml --profile=self-hosted build
29+
docker compose -f docker-compose-all.yaml --profile=self-hosted up -d --remove-orphans
30+
31+
- name: Prune docker artifacts on remote
32+
continue-on-error: true
33+
uses: appleboy/ssh-action@v1
34+
with:
35+
host: ${{ secrets.DB_SSH_HOST }}
36+
username: ${{ secrets.DB_SSH_USER }}
37+
key: ${{ secrets.DB_SSH_KEY }}
38+
script: |
39+
set -eu
2840
docker image prune -fa --filter "until=48h"
41+
docker builder prune -f --filter "until=48h"
2942
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}})"
43+
docker container ls --filter status=exited --format "::warning::container {{.ID}} {{.Status}} ({{.Names}})"

0 commit comments

Comments
 (0)