From e2daebedbd137114be22b231d70e5734af78be84 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Mon, 13 Oct 2025 10:48:50 -0700 Subject: [PATCH] feat: add database migration step to deployment workflow --- .github/workflows/deploy.yml | 12 +++++++++++- Dockerfile.migrate | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.migrate diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca324ca..ff98330 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -63,7 +63,7 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - - name: 🗄️ Build and Push to Container Registry + - name: 🗄️ Build and Push App to Container Registry uses: docker/build-push-action@v5 with: context: . @@ -74,6 +74,14 @@ jobs: build-args: | DATABASE_URL=${{ secrets.PROD_DATABASE_URL }} + - name: 🗄️ Build and Push Migration Image to Container Registry + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.migrate + push: true + tags: ${{ vars.CONTAINER_REGISTRY }}/brackt-migrate:latest + # This ugly bit is necessary if you don't want your cache to grow forever # till it hits GitHub's limit of 10GB. # Temp fix @@ -108,4 +116,6 @@ jobs: docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD cd brackt docker compose pull + docker pull $CONTAINER_REGISTRY/brackt-migrate:latest + docker run --rm --env-file .env $CONTAINER_REGISTRY/brackt-migrate:latest docker compose up -d diff --git a/Dockerfile.migrate b/Dockerfile.migrate new file mode 100644 index 0000000..90a5a1c --- /dev/null +++ b/Dockerfile.migrate @@ -0,0 +1,13 @@ +FROM node:20-alpine AS dependencies +COPY ./package.json package-lock.json /app/ +WORKDIR /app +RUN npm ci --omit=dev + +FROM node:20-alpine +COPY ./package.json package-lock.json /app/ +COPY --from=dependencies /app/node_modules /app/node_modules +COPY ./drizzle /app/drizzle +COPY ./drizzle.config.ts /app/drizzle.config.ts +COPY ./database /app/database +WORKDIR /app +CMD ["npx", "drizzle-kit", "migrate"]