Skip to content

Commit

Permalink
Prune system before building new image
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Mar 31, 2024
1 parent 1522641 commit 87f26aa
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,15 @@ jobs:
DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')"
DB_IMAGE="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .Image')"
# docker container commit "$DB_CONTAINER_ID" updated-db
# docker image ls "$DB_IMAGE"
#docker export "$DB_CONTAINER_ID" | docker import - "$DB_IMAGE"
# docker image ls "$DB_IMAGE"
# Persist and squash data in new image
docker cp "$DB_CONTAINER_ID:/var/lib/postgresql/postgres-data" db/postgres-data
echo "COPY postgres-data /var/lib/postgresql/postgres-data' >> db/Dockerfile
# Build and push including the new data
echo 'COPY postgres-data /var/lib/postgresql/postgres-data' >> db/Dockerfile
docker system prune --force --all --volumes
docker compose build --push db
# Squash image to reduce size by removing duplicated added/removed files in Docker layers
Expand Down

0 comments on commit 87f26aa

Please sign in to comment.