feat: dockerfile #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | ||
push: | ||
branches: [ FEAT/get-ci ] | ||
name: Prod Deploy to Amazon ECS | ||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.BAKO_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.BAKO_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
- name: Login to Amazon ECR | ||
id: login_ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
- name: Build and push Docker image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
env: | ||
ECR_NAME: bako-safe-api | ||
ECR_REGISTRY: ${{ steps.login_ecr.outputs.registry }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
with: | ||
context: ./packages/api | ||
file: ./packages/api/Dockerfile | ||
platforms: linux/arm64 | ||
push: true | ||
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_NAME }}:${{ env.IMAGE_TAG }} | ||
outputs: | ||
image: ${{ steps.docker_build.outputs.image }} | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task_def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ./packages/api/prod_task_definition.json | ||
container-name: bako-safe-api | ||
image: ${{ steps.docker_build.outputs.image }} | ||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task_def.outputs.task-definition }} | ||
service: bako-safe-api-service | ||
cluster: Bako-Safe-ECS | ||
wait-for-service-stability: true |