-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.api
45 lines (31 loc) · 966 Bytes
/
Dockerfile.api
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
45
# Stage 1: Build
FROM --platform=$BUILDPLATFORM node:20.15.0-slim AS builder
# Set environment variables
# Install pnpm
RUN npm install -g pnpm
# Set working directory
WORKDIR /app
# Copy the entire source code
COPY . .
# Install dependencies for the whole monorepo
RUN pnpm install
# Run Turborepo build for the specific project (api)
RUN pnpm run build:api
RUN pnpm run build:definition
# Stage 2: Production
FROM --platform=$TARGETPLATFORM node:20.15.0-slim AS production
ENV MONGO_URI=""
ENV GCLOUD_SECRET_NAME="service-account-keyfile"
# Install pnpm
RUN npm install -g pnpm
WORKDIR /app
# Copy root package.json and lockfile
COPY package.json pnpm-lock.yaml turbo.json pnpm-workspace.yaml ./
# Copy the needed folder
COPY --from=builder /app/apps/api ./apps/api
COPY --from=builder /app/packages ./packages
RUN pnpm install --production
# Expose the port the app runs on
EXPOSE 8888
# Command to run the API
CMD ["node", "apps/api/dist/main.js"]