feat: bring back schema migrations

This commit is contained in:
2025-03-22 22:29:36 +01:00
parent 72d49df94c
commit 6b82975350
5 changed files with 86 additions and 4 deletions

View File

@@ -41,7 +41,46 @@ jobs:
secrets: |
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
db:
name: Push db to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: srizan10/hclive-db
tags: latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./apps/db/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
secrets: |
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
TURBO_TEAM=${{ secrets.TURBO_TEAM }}
deploy:
name: Deploy to server
runs-on: ubuntu-latest
needs: [frontend, db]
steps:
- name: Emit a webhook to the server
env:
AUTH_HEADER: ${{ secrets.WHSERVER_TOKEN }}

View File

@@ -11,7 +11,6 @@
"lint": "next lint",
"ui:add": "shadcn add",
"prepare": "next-ws patch",
"act": "act --secret-file .env.ci",
"check-types": "tsc --noEmit"
},
"dependencies": {
@@ -41,7 +40,7 @@
"lucia": "^3.2.2",
"lucide-react": "^0.473.0",
"media-chrome": "^4.8.0",
"next": "^15.1.6",
"next": "^15.2.3",
"next-themes": "^0.4.4",
"next-ws": "^2.0.4",
"react": "19",

View File

@@ -12,7 +12,7 @@
"dev": "turbo run dev",
"lint": "turbo run lint",
"docker:web": "dotenvx run -f .env.docker -- docker buildx build --platform linux/amd64 -f apps/web/Dockerfile . --build-arg TURBO_TEAM=\"ducktors\" --secret id=TURBO_TOKEN,env=TURBO_TOKEN --secret id=TURBO_TEAM,env=TURBO_TEAM --no-cache",
"denv:install": "curl -fsS https://dotenvx.sh | sudo sh"
"act": "act --secret-file .env.ci"
},
"devDependencies": {
"turbo": "^2.4.4"

44
packages/db/Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
FROM node:lts-alpine AS base
FROM base AS builder
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo@^2
COPY . .
# Generate a partial monorepo with a pruned lockfile for the db package
RUN turbo prune @hctv/db --docker
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# First install the dependencies
COPY --from=builder /app/out/json/ .
RUN yarn install --frozen-lockfile
COPY --from=builder /app/out/full/ .
RUN --mount=type=secret,id=TURBO_TOKEN --mount=type=secret,id=TURBO_TEAM TURBO_TOKEN=$(cat /run/secrets/TURBO_TOKEN) TURBO_TEAM=$(cat /run/secrets/TURBO_TEAM) yarn turbo run build --filter=@hctv/db
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 prisma
USER prisma
COPY --from=installer --chown=prisma:nodejs /app/packages/db ./packages/db
COPY --from=installer --chown=prisma:nodejs /app/node_modules ./node_modules
COPY --from=installer --chown=prisma:nodejs /app/package.json ./package.json
# Set environment variables for database connection
ENV NODE_ENV=production
# Set the working directory to the db package
WORKDIR /app/packages/db
# Run Prisma migrations as the entrypoint
ENTRYPOINT ["npx", "prisma", "migrate", "deploy"]

View File

@@ -3855,7 +3855,7 @@ next-ws@^2.0.4:
resolved "https://registry.yarnpkg.com/next-ws/-/next-ws-2.0.5.tgz#07798246548fcf1e0116a93fc32aae448901337f"
integrity sha512-9AyLFtaOJ4UY65Qzz6Z1WQ6rjMEskKRYcq1XzYGkrtEh56wJWLrdQ9dWbJkSmjWz35yY3TCaE5pYTOY/7Z1epA==
next@^15.1.6:
next@^15.2.3:
version "15.2.3"
resolved "https://registry.yarnpkg.com/next/-/next-15.2.3.tgz#1ac803c08076d47eb5b431cb625135616c6bec7e"
integrity sha512-x6eDkZxk2rPpu46E1ZVUWIBhYCLszmUY6fvHBFcbzJ9dD+qRX6vcHusaqqDlnY+VngKzKbAiG2iRCkPbmi8f7w==