Build and push services images
@@ -9,6 +9,41 @@ env:
TF_WORKSPACE: "production"
jobs:
+ build-and-push-service:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ service: [gateway, users-backend]
+
+ steps:
+ - uses: actions/checkout@master
+ - name: Docker login
+ run: aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com
+ env:
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ - name: Set up Docker Buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v1
+ - name: Cache Docker layers
+ uses: actions/cache@v2
+ with:
+ path: /tmp/.buildx-cache
+ key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ matrix.service }}
+ restore-keys: |
+ ${{ runner.os }}-buildx-
+ ${{ runner.os }}-buildx-${{ github.sha }}
+ - name: Build and push
+ uses: docker/build-push-action@v2
+ with:
+ context: ./${{ matrix.service }}
+ file: ./${{ matrix.service }}/Dockerfile
+ builder: ${{ steps.buildx.outputs.name }}
+ push: true
+ tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-central-1.amazonaws.com/pythonit/${{ matrix.service }}:production
+ cache-from: type=local,src=/tmp/.buildx-cache
+ cache-to: type=local,dest=/tmp/.buildx-cache
+
build-and-push-lambda-backend:
runs-on: ubuntu-latest
@@ -41,7 +76,7 @@ jobs:
terraform:
runs-on: ubuntu-latest
- needs: [build-and-push-lambda-backend]
+ needs: [build-and-push-lambda-backend, build-and-push-service]
defaults:
run:
working-directory: ./infrastructure/applications
@@ -86,12 +121,12 @@ jobs:
TF_VAR_service_to_service_secret: ${{ secrets.TF_VAR_service_to_service_secret }}
TF_VAR_pastaporto_action_secret: ${{ secrets.TF_VAR_pastaporto_action_secret }}
- migrate-db:
+ migrate-pycon-backend-db:
runs-on: ubuntu-latest
needs: [terraform]
steps:
- uses: actions/checkout@master
- - name: Migrate DB
+ - name: Migrate PyCon Backend DB
run: 'aws lambda invoke --function-name production-pycon-backend --cli-binary-format raw-in-base64-out --payload ''{ "_serverless-wsgi": { "command": "manage", "data": "migrate" } }'' response.json'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
