-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docker): adding in docker building
- Loading branch information
Showing
5 changed files
with
192 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: 'Re-usable Docker Build Flow' | ||
description: 'Used to setup and build a docker image' | ||
inputs: | ||
scope: | ||
description: 'Turbo Repo scope to run the build for' | ||
required: true | ||
docker-repo-name: | ||
description: 'Docker name of the repo <account-id>.dkr.ecr.us-east-1.amazonaws.com/<name>' | ||
required: true | ||
app-path: | ||
description: 'The path of where the application is located in the monorepo ie servers/<app-name>' | ||
required: true | ||
app-port: | ||
description: 'The port the application runs on ie 4006' | ||
required: true | ||
sentry-org: | ||
description: 'The org name used in sentry. Used to upload source maps' | ||
required: false | ||
default: pocket | ||
sentry-project: | ||
description: 'The project name used in sentry. Used to upload source maps' | ||
required: true | ||
sentry-token: | ||
description: 'The token used for sentry. Used to upload source maps' | ||
required: true | ||
push: | ||
description: Whether or not to push the image | ||
required: true | ||
default: 'false' | ||
dockerhub-username: | ||
description: Docker hub username | ||
required: true | ||
dockerhub-token: | ||
description: Dockerhub Token | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
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: ${{ inputs['dockerhub-username'] }} | ||
password: ${{ inputs['dockerhub-token'] }} | ||
|
||
- name: Build docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: ${{inputs['push']}} | ||
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']}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
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-short-hand: | ||
description: 'Docker name of the repo <account-id>.dkr.ecr.us-east-1.amazonaws.com/<name>' | ||
required: true | ||
type: string | ||
development-aws-registry: | ||
description: 'AWS Development Account Id' | ||
type: string | ||
default: 410318598490.dkr.ecr.us-east-1.amazonaws.com | ||
production-aws-registry: | ||
description: 'AWS Development Account Id' | ||
type: string | ||
default: 410318598490.dkr.ecr.us-east-1.amazonaws.com | ||
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: number | ||
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 | ||
|
||
jobs: | ||
# Let's build the image on every pull request just like we would on production | ||
pull-request: | ||
# Only run this job on a pull request event | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build Docker Image | ||
# Use our re-usable containerize action | ||
uses: ./.github/actions/containerize | ||
with: | ||
docker-repo-name: ${{inputs['development-aws-registry']}}/${{inputs['docker-repo-name-short-hand']}}-prod-app | ||
app-path: ${{inputs['app-path']}} | ||
app-port: ${{inputs['app-port']}} | ||
sentry-project: ${{inputs['sentry-project']}} | ||
sentry-org: ${{inputs['sentry-org']}} | ||
sentry-token: ${{secrets.SENTRY_BEARER}} | ||
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}} | ||
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}} | ||
scope: ${{inputs['scope']}} | ||
|
||
development: | ||
if: github.ref == 'refs/heads/dev' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build and Push Development Docker Image | ||
# Use our re-usable containerize action | ||
uses: ./.github/actions/containerize | ||
with: | ||
docker-repo-name: ${{inputs['development-aws-registry']}}/${{inputs['docker-repo-name-short-hand']}}-dev-app | ||
app-path: ${{inputs['app-path']}} | ||
app-port: ${{inputs['app-port']}} | ||
sentry-project: ${{inputs['sentry-project']}} | ||
sentry-org: ${{inputs['sentry-org']}} | ||
sentry-token: ${{secrets.SENTRY_BEARER}} | ||
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}} | ||
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}} | ||
scope: ${{inputs['scope']}} | ||
push: false | ||
|
||
|
||
production: | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# While we wait for docker compose to be healthy we install node and needed packages for this service | ||
- name: Build and Push Production Docker Image | ||
# Use our re-usable containerize action | ||
uses: ./.github/actions/containerize | ||
with: | ||
docker-repo-name: ${{inputs['development-aws-registry']}}/${{inputs['docker-repo-name-short-hand']}}-prod-app | ||
app-path: ${{inputs['app-path']}} | ||
app-port: ${{inputs['app-port']}} | ||
sentry-project: ${{inputs['sentry-project']}} | ||
sentry-org: ${{inputs['sentry-org']}} | ||
sentry-token: ${{secrets.SENTRY_BEARER}} | ||
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}} | ||
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}} | ||
scope: ${{inputs['scope']}} | ||
# Ensure the re-usable workflow is allowed to access the secrets |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters