Spaces:
Paused
Paused
| # 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 | |