Skip to content

Commit

Permalink
docker image experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmegatelo committed Jan 21, 2025
1 parent 70f608d commit 8d487ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ on:

jobs:
build:
name: Build image
name: Build docker images
runs-on: ubuntu-latest
environment: production
strategy:
matrix:
image_name: ['django', 'frontend']
steps:
- uses: actions/checkout@master
- run: docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }}
- run: docker build -f ./infra/production/django/Dockerfile -t ghcr.io/$GITHUB_ACTOR/walter:latest -t ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA .
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter:latest
- run: docker build -f ./infra/production/${{matrix.image_name}}/Dockerfile -t ghcr.io/$GITHUB_ACTOR/walter-${{matrix.image_name}}:latest -t ghcr.io/$GITHUB_ACTOR/walter-${{matrix.image_name}}:$GITHUB_SHA .
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter-${{matrix.image_name}}:$GITHUB_SHA
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter-${{matrix.image_name}}:latest

deploy:
name: Deploy
Expand Down Expand Up @@ -59,4 +62,4 @@ jobs:
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} -r $(pwd)/* ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} .env ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter/.env
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} docker-compose.prod.yml ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter/docker-compose.prod.yml
- run: ssh -i ${{ env.SSH_KEY_PATH }} ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }} "cd /home/walter/walter && docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }} && docker pull ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA && docker compose -f docker-compose.prod.yml up -d --build && docker system prune --all --force"
- run: ssh -i ${{ env.SSH_KEY_PATH }} ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }} "cd /home/walter/walter && docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }} && docker pull ghcr.io/$GITHUB_ACTOR/walter-web:$GITHUB_SHA && docker pull ghcr.io/$GITHUB_ACTOR/walter-frontend:$GITHUB_SHA && docker compose -f docker-compose.prod.yml up -d && docker system prune --all --force"
8 changes: 2 additions & 6 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ services:
- ./certbot/conf/:/etc/letsencrypt/:rw

web:
build:
context: .
dockerfile: infra/production/django/Dockerfile
image: ghcr.io/mrmegatelo/walter-django:${GITHUB_SHA:-latest}
command: /start
volumes:
- staticfiles:/app/staticfiles
Expand All @@ -44,9 +42,7 @@ services:
condition: service_started

frontend:
build:
context: .
dockerfile: ./infra/local/frontend/Dockerfile
image: ghcr.io/mrmegatelo/walter-frontend:${GITHUB_SHA:-latest}
command: build
volumes:
- ./frontend:/app
Expand Down

0 comments on commit 8d487ed

Please sign in to comment.