-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathDockerfile.api
More file actions
73 lines (55 loc) · 1.93 KB
/
Dockerfile.api
File metadata and controls
73 lines (55 loc) · 1.93 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM node:24-alpine AS base
# Accept git SHA as build argument
ARG GIT_SHA
LABEL git.sha=${GIT_SHA}
ENV GIT_SHA=${GIT_SHA}
# Install pnpm, infisical CLI, and ca-certificates
RUN npm install -g pnpm@10.15.0
RUN apk add --no-cache curl ca-certificates bash && \
curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | distro=alpine version=3.18.0 codename= bash && \
apk add infisical && \
update-ca-certificates
# Set the working directory
WORKDIR /app
# Copy workspace files
COPY pnpm-workspace.yaml ./
COPY package.json ./
COPY pnpm-lock.yaml ./
# Copy all packages (workspace dependencies)
COPY packages/ ./packages/
COPY apps/api/ ./apps/api/
# Install dependencies using pnpm
RUN pnpm install --frozen-lockfile
# Build all workspace packages first
RUN pnpm --filter "./packages/*" build
# Build the api service
WORKDIR /app/apps/api
RUN pnpm build
# Production stage
FROM node:24-alpine AS runner
# Install pnpm, infisical CLI, and ca-certificates
RUN npm install -g pnpm@10.15.0
RUN apk add --no-cache curl ca-certificates bash && \
curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | distro=alpine version=3.18.0 codename= bash && \
apk add infisical && \
update-ca-certificates
WORKDIR /app
# Copy workspace files
COPY pnpm-workspace.yaml ./
COPY package.json ./
COPY pnpm-lock.yaml ./
# Copy built packages
COPY --from=base /app/packages/ ./packages/
COPY --from=base /app/apps/api/dist/ ./apps/api/dist/
COPY --from=base /app/apps/api/package.json ./apps/api/package.json
COPY --from=base /app/apps/api/openapi.yaml ./apps/api/openapi.yaml
# Copy ca-certificates from build stage
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Install only production dependencies
RUN pnpm install --frozen-lockfile --prod
# Set working directory to api app
WORKDIR /app/apps/api
# Expose port
EXPOSE 3000
# Start the application
CMD ["pnpm", "start"]