diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d372242..218ad01 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -64,3 +64,24 @@ jobs: cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 + # Push to AWS ECR for App Runner auto-deploy + - name: Configure AWS credentials + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-1 + + - name: Login to Amazon ECR + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Push to ECR (triggers App Runner auto-deploy) + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + run: | + docker pull ghcr.io/${{ github.repository }}:latest + docker tag ghcr.io/${{ github.repository }}:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-1.amazonaws.com/next-ai-draw-io:latest + docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-1.amazonaws.com/next-ai-draw-io:latest + diff --git a/.gitignore b/.gitignore index 5f18be3..68b13ab 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ push-via-ec2.sh .dev.vars .open-next/ .wrangler/ +.env*.local diff --git a/Dockerfile b/Dockerfile index 8ab2670..d861242 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,6 +54,6 @@ EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" -# Start the application -CMD ["node", "server.js"] +# Start the application (HOSTNAME override needed for AWS App Runner) +CMD ["sh", "-c", "HOSTNAME=0.0.0.0 exec node server.js"]