-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (26 loc) · 919 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (26 loc) · 919 Bytes
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
# Development stage
FROM node:18 AS development
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install all dependencies (including devDependencies)
RUN npm install
# Copy the rest of the code
COPY . .
# Build the TypeScript code
RUN npm run build || (echo "Build failed. Check the errors above." && exit 1)
# Command to run the app in development mode
CMD ["npm", "run", "dev"]
# Production stage
FROM node:18 AS production
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built JavaScript files from the development stage
COPY --from=development /usr/src/app/dist ./dist
# Copy data
COPY --from=development /usr/src/app/src/data ./dist/data
# Command to run the app in production mode
CMD ["node", "dist/index.js"]