Skip to content

Commit

Permalink
Added GitHub action for docker image building
Browse files Browse the repository at this point in the history
As per subject, builds a docker image on every git commit and pushes
the image to AWS ECR
  • Loading branch information
dotemacs committed Jul 30, 2024
1 parent dc288cb commit 410ec1a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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: 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 fb-user-datastore, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: "fb-user-datastore"
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -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 410ec1a

Please sign in to comment.