File size: 844 Bytes
ee426b0
 
 
 
 
 
 
 
a0a7d0f
 
 
 
 
 
ee426b0
 
 
a0a7d0f
ee426b0
 
 
 
 
a0a7d0f
 
ee426b0
 
a0a7d0f
ee426b0
 
 
 
 
a0a7d0f
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
# Use Node.js as base image
FROM node:14

# Install PM2 and NGINX
RUN npm install -g pm2 \
    && apt-get update \
    && apt-get install -y nginx

# Set working directory and set permissions
RUN mkdir -p /app && chown -R node:node /app

# Change the user from root to node
USER node

WORKDIR /app

# Copy package.json and package-lock.json
COPY --chown=node:node package*.json ./

# Install dependencies
RUN npm install

# Copy app.js and generate-config.js
COPY --chown=node:node app.js .
COPY --chown=node:node generate-config.js .

# Copy NGINX main config file
COPY --chown=node:node nginx.conf /etc/nginx/

# Generate config files and start the applications at runtime
CMD ["sh", "-c", "node generate-config.js && cp default.conf /etc/nginx/conf.d/ && pm2 start ecosystem.config.js && nginx -g 'daemon off;'"]

# Expose ports
EXPOSE 7860