Skip to content

Commit

Permalink
Fix docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
vpasquier committed Dec 29, 2024
1 parent 4fe3bb6 commit e8012e1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/deploy_ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ jobs:
run: |
aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.ECR_REGISTRY }}
# Build and tag the Docker image
docker build \
-t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest \
--build-arg COMMIT_SHA=${{ github.sha }} -f Dockerfile .
# Build the Docker image with the IMAGE_NAME only
docker build -t ${{ env.IMAGE_NAME }} -f Dockerfile .
# Tag the image with the full registry and repository
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_NAME }}-latest
# Delete the latest image tag if it exists before pushing
aws ecr batch-delete-image --repository-name ${{ env.ECR_REPOSITORY }}/${{ env.IMAGE_NAME }} --image-ids imageTag=latest || true
aws ecr batch-delete-image --repository-name ${{ env.ECR_REPOSITORY }} --image-ids imageTag=${{ env.IMAGE_NAME }}-latest || true
# Push the latest tag
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_NAME }}-latest
- name: Update ECS task definition
run: |
Expand Down Expand Up @@ -91,10 +92,11 @@ jobs:
run: |
aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.ECR_REGISTRY }}
# Build and tag the Docker image with the input tag
docker build \
-t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.tag }} \
--build-arg COMMIT_SHA=${{ github.sha }} -f Dockerfile .
# Build the Docker image with the IMAGE_NAME only
docker build -t ${{ env.IMAGE_NAME }} -f Dockerfile .
# Tag the image with the full registry and repository using the input tag
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_NAME }}-${{ github.event.inputs.tag }}
# Push the tagged image
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.tag }}
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_NAME }}-${{ github.event.inputs.tag }}

0 comments on commit e8012e1

Please sign in to comment.