Skip to content

Fix: Dockerfile production variable mismatch #7

Fix: Dockerfile production variable mismatch

Fix: Dockerfile production variable mismatch #7

Workflow file for this run

name: Build and Push to ECR
on:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'
push:
branches:
- prod
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS credentials
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: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Prepare backend build context
run: |
echo "Copying backend files to build context..."
mkdir -p build-context
cp -r apps/backend/src build-context/
cp apps/backend/Dockerfile.prod build-context/
cp requirements.txt build-context/
- name: Build, tag, and push image to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
echo "Building image..."
docker build -f build-context/Dockerfile.prod -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG build-context
echo "Tagging image as latest..."
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
$ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "Pushing image with tag $IMAGE_TAG..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "Pushing image with tag latest..."
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest