refactor: consolidate migration and app containers into single production image

This commit is contained in:
Chris Parsons 2025-10-13 11:01:12 -07:00
parent e2daebedbd
commit f72b98fdda
5 changed files with 9 additions and 26 deletions

View file

@ -1,4 +1,6 @@
NODE_ENV="development"
DATABASE_URL=""
CLERK_SECRET_KEY=""
VITE_CLERK_PUBLISHABLE_KEY=""
CLERK_PUBLISHABLE_KEY=""
CLERK_WEBHOOK_SECRET=""
CONTAINER_REGISTRY=""

View file

@ -63,7 +63,7 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: 🗄️ Build and Push App to Container Registry
- name: 🗄️ Build and Push to Container Registry
uses: docker/build-push-action@v5
with:
context: .
@ -74,14 +74,6 @@ 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
@ -116,6 +108,4 @@ 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

View file

@ -18,5 +18,8 @@ FROM node:20-alpine
COPY ./package.json package-lock.json server.js /app/
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
COPY --from=build-env /app/build /app/build
COPY ./drizzle /app/drizzle
COPY ./drizzle.config.ts /app/drizzle.config.ts
COPY ./database /app/database
WORKDIR /app
CMD ["npm", "run", "start"]
CMD ["npm", "run", "start:production"]

View file

@ -1,13 +0,0 @@
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"]

View file

@ -8,6 +8,7 @@
"db:migrate": "dotenv -- drizzle-kit migrate",
"dev": "dotenv -- node server.js",
"start": "node server.js",
"start:production": "drizzle-kit migrate && rm -rf drizzle drizzle.config.ts database && node server.js",
"typecheck": "react-router typegen && tsc -b"
},
"dependencies": {