Skip to content

Commit

Permalink
Added GitHub CI workflow for docker image building
Browse files Browse the repository at this point in the history
Added the docker image building & pushing to Amazon's ECR, for both
editor and worker services.
  • Loading branch information
dotemacs committed Jul 25, 2024
1 parent a33ff5f commit a6b23b6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and upload docker images

on:
push:
branches:
- '**'

permissions:
id-token: write # for JWT request
contents: read # for actions/checkout

jobs:
docker-image-build:
name: docker-image-build
runs-on: ubuntu-latest
environment: preprod
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Checkout repo
uses: actions/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-2
role-session-name: github-aws-access
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/[email protected]
- name: Build editor, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: "fb-editor"
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f docker/web/Dockerfile -t ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} .
docker tag ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
- name: Build worker, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: "fb-worker"
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f docker/workers/Dockerfile -t ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} .
docker tag ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}

0 comments on commit a6b23b6

Please sign in to comment.