-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (28 loc) · 1.2 KB
/
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
### Multistage build
# Base image
FROM node:latest AS BASE
# Switch the working directory
WORKDIR /usr/src/app
# Copy the package.json and package-lock.json first
COPY package*.json ./
# Install dependencies
RUN apt -qq update && apt -qq upgrade -y && apt -qq install --no-install-recommends python3 python3-pip python3-geojson python3-pandas python3-redis -y && rm -rf /var/lib/apt/lists/* && pip3 install -U textblob && npm i -g [email protected]&& npm i -g pm2@latest
### 2nd Stage: Install dependencies
FROM BASE AS DEPENDENCIES
# Install the dependencies => node_modules
RUN npm ci --production
### 43rd Stage: Create the final image
FROM BASE AS RELEASE
# Copy node_modules [from DEDENCIES to RLEASE]
COPY --from=DEPENDENCIES /usr/src/app/node_modules ./node_modules
# Copy rest of the files [from local to RELEASE]
COPY . .
# Node module tweaks + Grant permission to non-root user
WORKDIR /usr/src/app/nodeModuleconfig
RUN chmod +x nodeCus.sh && ./nodeCus.sh && chown -R 1000:1000 /usr/src/app
# Switch back to the project root
WORKDIR /usr/src/app
# Run the service with non-root user
USER 1000:1000
# Command to execute at the end, each parameters in an element in the array
CMD ["pm2-runtime", "start","pm2.json"]