-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (26 loc) · 860 Bytes
/
Dockerfile
File metadata and controls
41 lines (26 loc) · 860 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
40
FROM node:22-alpine
WORKDIR /app
RUN chown node:node /app
# Set environment variable NODE_ENV if provided, default to 'production'
# ARG NODE_ENV=production
# ENV NODE_ENV=$NODE_ENV
USER node
WORKDIR /app
# Copy package.json and gulpfile.js first to leverage Docker cache
# This is needed for npm ci step to install dependencies
# gulp files and client directory are needed for serving static css, js, img files
COPY --chown=node:node package*.json ./
COPY --chown=node:node gulp*.js ./
COPY --chown=node:node client/ ./client/
# for debugging purposes
# RUN node --version && npm --version && ls
RUN npm ci
# for debugging purposes
# RUN ls -l node_modules/.bin
COPY . ./
# Switch to root user to run npm prune
USER root
# Remove dev dependencies and unnecessary files
RUN npm prune --production
USER node
CMD ["node", "--harmony", "./app.js"]