-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
44 lines (30 loc) · 965 Bytes
/
Dockerfile
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
# Use a minimal Node.js base image
FROM node:18-alpine as base
# Enable pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Builder stage
FROM base AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy the rest of the project files
COPY . .
# Build the TypeScript code to JavaScript
RUN pnpm run build
# Final runtime image
FROM base
# Set the working directory inside the container
WORKDIR /app
# Copy the package.json and pnpm-lock.yaml files from the builder image
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
# Copy the built JavaScript files from the builder image
COPY --from=builder /app/dist ./dist
# Install production dependencies
RUN pnpm install --prod --frozen-lockfile
# Web API
EXPOSE 3000
# Start the application
CMD ["node", "dist/main.js"]