feat: add database migration step to deployment workflow
This commit is contained in:
parent
c343521706
commit
e2daebedbd
2 changed files with 24 additions and 1 deletions
12
.github/workflows/deploy.yml
vendored
12
.github/workflows/deploy.yml
vendored
|
|
@ -63,7 +63,7 @@ jobs:
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
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
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
|
@ -74,6 +74,14 @@ jobs:
|
||||||
build-args: |
|
build-args: |
|
||||||
DATABASE_URL=${{ secrets.PROD_DATABASE_URL }}
|
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
|
# This ugly bit is necessary if you don't want your cache to grow forever
|
||||||
# till it hits GitHub's limit of 10GB.
|
# till it hits GitHub's limit of 10GB.
|
||||||
# Temp fix
|
# Temp fix
|
||||||
|
|
@ -108,4 +116,6 @@ jobs:
|
||||||
docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
|
docker login $CONTAINER_REGISTRY -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
|
||||||
cd brackt
|
cd brackt
|
||||||
docker compose pull
|
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
|
docker compose up -d
|
||||||
|
|
|
||||||
13
Dockerfile.migrate
Normal file
13
Dockerfile.migrate
Normal file
|
|
@ -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"]
|
||||||
Loading…
Add table
Reference in a new issue