fix: dockerignore #27
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
name: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- develop | |
env: | |
ENV: dev | |
AWS_REGION: ap-northeast-1 | |
AWS_ACCOUNT_ID: 905418376731 | |
BASE_URL: https://api.dev.magi-sche.org | |
PORT: 8080 | |
FRONTEND_ENDPOINT: https://dev.magi-sche.org | |
OAUTH_DEFAULT_RETURN_URL: https://dev.magi-sche.org/callback | |
CORS_ORIGINS: https://dev.magi-sche.org | |
ACCESS_TOKEN_EXPIRE_MINUTES: 5 | |
# 60 days = 30 * 24 * 60 = 43200 minutes | |
REFRESH_TOKEN_EXPIRE_MINUTES: 86400 | |
SQL_LOG: true | |
jobs: | |
build-and-push: | |
outputs: | |
ecr_image_name: ${{ steps.set_outputs.outputs.ecr_image_name }} | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::905418376731:role/magische-${{ env.ENV }}-api-deploy | |
aws-region: ${{ env.AWS_REGION }} | |
- name: login to ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
id: login-ecr | |
- id: set_env | |
name: set env | |
run: | | |
echo "image_tag=build-$(date +%Y%m%d)-${{ github.sha }}" >> $GITHUB_OUTPUT | |
echo "ecr_repository_name=${{ steps.login-ecr.outputs.registry }}/magische-${{ env.ENV }}-api" >> $GITHUB_OUTPUT | |
- id: set_outputs | |
name: set outputs | |
run: | | |
echo "ecr_image_name=${{ steps.set_env.outputs.ecr_repository_name }}:${{ steps.set_env.outputs.image_tag }}" >> $GITHUB_OUTPUT | |
- uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: | | |
ghcr.io/${{ github.repository }}/server | |
${{ steps.set_env.outputs.ecr_repository_name }} | |
tags: | | |
type=raw,value=${{ steps.set_env.outputs.image_tag }} | |
type=raw,value=latest | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
target: deploy | |
platforms: linux/amd64,linux/arm64 | |
deploy: | |
environment: | |
name: dev | |
permissions: | |
id-token: write | |
contents: read | |
needs: [build-and-push] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::905418376731:role/magische-${{ env.ENV }}-api-deploy | |
aws-region: ${{ env.AWS_REGION }} | |
- uses: kayac/ecspresso@v2 | |
with: | |
version-file: ./infra/ecs/.ecspresso-version | |
- working-directory: ./infra/ecs | |
run: | | |
ecspresso deploy --config ecspresso.yml | |
env: | |
TFE_TOKEN: ${{ secrets.TFE_TOKEN }} | |
TFC_WORKSPACE: magische_infra_${{ env.ENV }} | |
AWS_REGION: ${{ env.AWS_REGION }} | |
AWS_ACCOUNT_ID: ${{ env.AWS_ACCOUNT_ID }} | |
ENV: ${{ env.ENV }} | |
IMAGE_NAME: ${{ needs.build-and-push.outputs.ecr_image_name }} | |
CPU: 256 | |
MEMORY: 512 | |
CPU_ARCHITECTURE: ARM64 |