-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (26 loc) · 887 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
# Stage 1: Build the TypeScript application
FROM node:22-alpine AS build
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock)
COPY package*.json yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Copy the rest of the application code
COPY . .
# Build the TypeScript application
RUN yarn build
# Stage 2: Create the production image
FROM node:22-alpine
# Set the working directory
WORKDIR /app
# Copy only the necessary files from the build stage
COPY --from=build /app/dist ./dist
COPY --from=build /app/package*.json ./
COPY --from=build /app/yarn.lock ./
# Install only production dependencies
RUN yarn install --frozen-lockfile --production
# Expose the port the app listens on (replace with your app's port)
EXPOSE 3000
# Command to start the application
CMD ["node", "dist/index.js"]