Skip to content

Commit

Permalink
chore(ci): adding in docker image building
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Aug 14, 2024
1 parent 9307259 commit 5056e79
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/containerize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 'Re-usable Docker Build Flow'
on:
workflow_call:
inputs:
scope:
description: 'Turbo Repo scope to run the build for'
required: true
type: string
docker-repo-name:
description: 'Docker name of the repo <account-id>.dkr.ecr.us-east-1.amazonaws.com/<name>'
required: true
type: string
app-path:
description: 'The path of where the application is located in the monorepo ie servers/<app-name>'
required: true
type: string
app-port:
description: 'The port the application runs on ie 4006'
required: true
type: int
sentry-org:
description: 'The org name used in sentry. Used to upload source maps'
required: false
type: string
default: pocket
sentry-project:
description: 'The project name used in sentry. Used to upload source maps'
required: true
type: string
sentry-token:
description: 'The token used to access sentry. Used to upload source maps'
required: false
type: string
default: ${{ secrets.SENTRY_BEARER }}

jobs:
main:
runs-on: ubuntu-latest
steps:
# can be useful if you want to add emulation support with QEMU to be able to build against more platforms.
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# action will create and boot a builder using by default the docker-container driver.
# This is not required but recommended using it to be able to build multi-platform images, export cache, etc.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build docker image
uses: docker/build-push-action@v6
with:
push: false
tags: ${{inputs['docker-repo-name']}}:${{ github.sha }}
build-args: |
GIT_SHA=${{ github.sha }}
SCOPE=${{inputs['scope']}}
APP_PATH=${{inputs['app-path']}}
SENTRY_AUTH_TOKEN=${{inputs['sentry-token']}}
SENTRY_ORG=${{inputs['sentry-org']}}
SENTRY_PROJECT=${{inputs['sentry-project']}}
PORT=${{inputs['app-port']}}
2 changes: 2 additions & 0 deletions .github/workflows/list-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
jobs:
# Let's test the service against some real life and mocked docker services.
test-integrations:
# Only run this job on a pull request event
if: github.event_name == 'pull_request'
# Use our re-usable test integrations workflow which will use our docker compose file
uses: ./.github/workflows/test-integrations.yml
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# A set of jobs that should always run no matter what on all Pull Requests in this repo
name: Pull Request
on:
- pull_request
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/user-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,36 @@ on:
- 'pnpm-lock.yaml'
- '.github/actions/**'
- '.github/workflows/user_api.yml'
push:
branches:
- main
- dev

jobs:
# Let's test the service against some real life and mocked docker services.
test-integrations:
# Only run this job on a pull request event
if: github.event_name == 'pull_request'
# Use our re-usable test integrations workflow which will use our docker compose file
uses: ./.github/workflows/test-integrations.yml
with:
# Only run the tests for our service
scope: 'user-api'
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

# Let's test the service against some real life and mocked docker services.
build-image:
# Only run this job on a pull request event
if: github.event_name == 'pull_request'
# Use our re-usable test integrations workflow which will use our docker compose file
uses: ./.github/workflows/containerize.yml
with:
# Only run the tests for our service
scope: 'user-api'
docker-repo-name: 410318598490.dkr.ecr.us-east-1.amazonaws.com/listapi-dev-app
app-path: servers/list-api
app-port: 4005
sentry-project: list-api
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

0 comments on commit 5056e79

Please sign in to comment.