Skip to content

Commit 3d109fd

Browse files
authored
Merge pull request #70 from ItzNotABug/tweak-docker-file
Tweak: `Dockerfile`
2 parents d05f560 + 9cf0f11 commit 3d109fd

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
# Build stage
2-
FROM node:18-alpine
2+
FROM node:18-alpine AS deps
33

4-
# Label
5-
LABEL author="@ItzNotABug"
4+
# Set working directory
5+
WORKDIR /usr/src/app
6+
7+
# Copy package.json and package-lock.json
8+
COPY package*.json ./
9+
10+
# Install only production dependencies
11+
RUN npm ci --omit-dev
12+
13+
# Build stage renamed for clarity, no actual build commands though
14+
FROM node:18-alpine AS runner
615

716
# Set working directory
817
WORKDIR /usr/src/app
918

19+
# Copy node_modules from 'deps' stage
20+
COPY --from=deps /usr/src/app/node_modules ./node_modules
21+
1022
# Copy the rest of your application code
1123
COPY . .
1224

25+
# Label
26+
LABEL author="@ItzNotABug"
27+
1328
# Install PM2 globally
1429
RUN npm install pm2 -g
1530

16-
# Install dependencies
17-
RUN npm ci --omit-dev
18-
1931
# Start your app
20-
CMD ["pm2-runtime", "start", "app.js", "--name", "ghosler-app"]
32+
CMD ["pm2-runtime", "start", "app.js", "--name", "ghosler-app"]

0 commit comments

Comments
 (0)