-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile
43 lines (30 loc) · 995 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
# Stage 1: Building the code
FROM node:21-alpine as builder
# Set the working directory in the container
WORKDIR /usr/src/api
RUN npm i -g pnpm
# Copy package.json
COPY ./api/package.json ./
COPY pnpm-lock.yaml ..
COPY pnpm-workspace.yaml ..
# Install npm dependencies
RUN pnpm install
# Copy the rest of your application's source code
COPY api/ ./
# Compile TypeScript to JavaScript
RUN npm run build
# Stage 2: Run the built code with only production dependencies
FROM node:21-alpine
WORKDIR /usr/src/api
# Copy built artifacts from the builder stage
COPY --from=builder /usr/src/api/dist ./dist
COPY --from=builder /usr/src/api/.env.example ./.env.example
COPY --from=builder /usr/src/api/drizzle ./drizzle
# Copy package.json (to run the application) and any other necessary files
COPY api/package.json ./
RUN npm i -g pnpm
# Install only production dependencies
RUN pnpm install --only=production
ENV NODE_ENV=production
# Command to run your app
CMD ["node", "dist/index.js"]