From 5d8c674fde07972337700c5469805c4bb2d4aab7 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 23 Jan 2024 11:06:26 -0600 Subject: [PATCH] Container image for migrator does not exist Problem ------- Deployments of the Unity Auth Service will need to migrate their database. A convenient way of delivering this is a container image that performs the necessary migrations. The Unity Auth Service does not have a container image for migrating the database. Solution -------- Add a Dockerfile and GitHub Actions workflow that builds a migrator image. The image will be pushed to the GitHub Container Registry. --- .github/workflows/migrator_image.yml | 60 ++++++++++++++++++++++++++++ .gitignore | 1 + MigratorDockerfile | 3 ++ 3 files changed, 64 insertions(+) create mode 100644 .github/workflows/migrator_image.yml create mode 100644 MigratorDockerfile diff --git a/.github/workflows/migrator_image.yml b/.github/workflows/migrator_image.yml new file mode 100644 index 0000000..7bba10a --- /dev/null +++ b/.github/workflows/migrator_image.yml @@ -0,0 +1,60 @@ +name: Create and publish a Docker image + +on: + workflow_dispatch: + push: + branches: + - main + # TODO: Remove this before merge. + - migrator + tags: + - v* + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Log in to the Container registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9dc751fe249ad99385a2583ee0d084c400eee04e + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-migrator + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 + with: + context: . + file: MigratorDockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore index 7516276..01fc4f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ /.gradle/ /.idea/ /.micronaut/ diff --git a/MigratorDockerfile b/MigratorDockerfile new file mode 100644 index 0000000..483ecdf --- /dev/null +++ b/MigratorDockerfile @@ -0,0 +1,3 @@ +FROM flyway/flyway:10-alpine + +COPY src/main/resources/db/migration /flyway/sql