Skip to content

Commit

Permalink
Docker: Improve cleanup
Browse files Browse the repository at this point in the history
We had dangling images due to dangling container.
But we cannot safely remove the containers in the same run, because we have two actions running in parallel that might interfere.
We use the grace period of 72h to secure this and remove everything that is old.
  • Loading branch information
tordans committed Jan 24, 2025
1 parent 488d46e commit 4ae71ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/deploy-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@ jobs:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
# Note on the "Cleanup docker"
# There might be a race condition with the other github action as we are building app an processing in parallel
# The 72h grace period should make sure nothing happend during the current build but old things get cleaned up
script: |
cd /srv
echo "Pulling latest 'app' image"
docker compose pull app
echo "Restarting 'app' container"
docker compose up app -d
echo "Pruning images"
docker image prune -fa
echo "Cleanup docker (containers and images) that are older than 72h"
docker container prune -f --filter "until=72h"
docker image prune -fa --filter "until=72h"
8 changes: 6 additions & 2 deletions .github/workflows/deploy-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ jobs:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
# Note on the "Cleanup docker"
# There might be a race condition with the other github action as we are building app an processing in parallel
# The 72h grace period should make sure nothing happend during the current build but old things get cleaned up
script: |
cd /srv
echo "Pulling latest 'processing' image"
docker compose pull processing
echo "Restarting 'processing' container"
docker compose up processing -d
echo "Pruning images"
docker image prune -fa
echo "Cleanup docker (containers and images) that are older than 72h"
docker container prune -f --filter "until=72h"
docker image prune -fa --filter "until=72h"
1 change: 0 additions & 1 deletion .github/workflows/restart-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ jobs:
echo "Restarting containers: tiles, db, traefik and proxy"
docker compose pull
docker compose -f docker-compose.yml -f docker-compose.network.yml up tiles db traefik proxy -d
docker image prune -fa

0 comments on commit 4ae71ff

Please sign in to comment.