mirror of
https://github.com/PeterMaquiran/tvone-api.git
synced 2026-04-22 03:55:50 +00:00
36 lines
923 B
Docker
36 lines
923 B
Docker
# Use the official Node.js image as the base image
|
|
FROM node:20
|
|
|
|
WORKDIR /app
|
|
|
|
# Enable pnpm
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
# Install deps
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copy source
|
|
COPY . .
|
|
|
|
# Ensure env exists (optional safety for containers)
|
|
RUN if [ ! -f .env ] && [ -f .env.example ]; then cp .env.example .env; fi
|
|
# Required by prisma generate during image build
|
|
ARG DATABASE_URL="postgres://tvone:tvone_password@db:5432/tvone"
|
|
ENV DATABASE_URL=$DATABASE_URL
|
|
|
|
# 2. Add the Prisma Schema specifically before generating
|
|
# This ensures the generator has the latest schema
|
|
COPY prisma ./prisma/
|
|
|
|
# 3. Generate Prisma Client
|
|
# We use 'pnpm exec' to ensure we use the local version synced with your node_modules
|
|
RUN pnpm exec prisma generate
|
|
|
|
# Build NestJS
|
|
RUN pnpm build
|
|
|
|
EXPOSE 3000
|
|
|
|
# Change your CMD to this:
|
|
CMD ["node", "dist/src/main.js"] |