-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (34 loc) · 1.03 KB
/
Dockerfile
File metadata and controls
40 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# ---- Base Stage ----
FROM node:22-alpine AS base
WORKDIR /usr/src/app
# ---- Dependencies Stage ----
FROM base AS deps
# Install pnpm
RUN npm install -g pnpm
# Copy dependency-defining files
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
COPY prisma ./prisma
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db?schema=public" pnpm prisma generate
# ---- Build Stage ----
FROM base AS build
RUN npm install -g pnpm
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY . .
# Build the application
RUN pnpm build
# ---- Production Dependencies ----
FROM deps AS prod-deps
RUN pnpm prune --prod
# ---- Production Stage ----
FROM base AS production
ENV NODE_ENV=production
# Copy built application from the build stage
COPY --from=build /usr/src/app/dist ./dist
# Copy production dependencies from the deps stage
COPY --from=prod-deps /usr/src/app/node_modules ./node_modules
# Expose the application port
EXPOSE 3000
# The command to run the application
CMD ["node", "dist/main.js"]