-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (30 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
44 lines (30 loc) · 1.2 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
41
42
43
44
# Build stage - compile TypeScript
FROM node:20 AS builder
WORKDIR /app
COPY package.json tsconfig.build.json ./
COPY src ./src
RUN yarn install
RUN cd src/backend && npx prisma generate
RUN yarn build:shared
RUN yarn build:backend
FROM node:20-slim
WORKDIR /app
# Install OpenSSL for Prisma (slim image needs this)
RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
COPY package.json ./
COPY src/backend/package.json ./src/backend/
COPY src/shared/package.json ./src/shared/
RUN yarn install --production
COPY --from=builder /app/src/backend/dist ./src/backend/dist
COPY --from=builder /app/src/shared/dist ./src/shared/dist
COPY --from=builder /app/src/backend/src/prisma ./src/backend/src/prisma
# Copy Prisma generated client from root node_modules (elevated there by yarn workspaces)
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
# Copy the entrypoint script to run migrations
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
EXPOSE 3001
# Use entrypoint to run migrations before starting app
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["yarn", "backend"]