diff --git a/packages/nodejs/Dockerfile b/packages/nodejs/Dockerfile index 4c7df1f..8900808 100644 --- a/packages/nodejs/Dockerfile +++ b/packages/nodejs/Dockerfile @@ -1,5 +1,5 @@ # syntax docker/dockerfile:latest -ARG nodejs_version=18 +ARG nodejs_version="18.16.0" ARG os_version="bullseye-slim" FROM node:${nodejs_version}-${os_version} AS build LABEL org.opencontainers.image.authors="BN Enginseers" \ @@ -10,15 +10,15 @@ LABEL org.opencontainers.image.authors="BN Enginseers" \ org.opencontainers.image.source="https://github.com/bn-digital/docker" \ org.opencontainers.image.licenses="MIT" ENV NODE_NO_WARNINGS="1" \ + NODE_ENV=production HOST="0.0.0.0" \ PORT="5000" \ - NODE_ENV=production WORKDIR /usr/local/src RUN npm install --global pm2 USER node EXPOSE $PORT COPY --chown=node . . ENTRYPOINT ["pm2-runtime"] -CMD ["--json", "process.yml"] +CMD ["ecosystem.config.yml"] FROM build diff --git a/packages/nodejs/bin/app.js b/packages/nodejs/bin/app.js new file mode 100644 index 0000000..8cd3185 --- /dev/null +++ b/packages/nodejs/bin/app.js @@ -0,0 +1,10 @@ +#!/usr/bin/env node +const strapi = require("@strapi/strapi"); +const fs = require("fs"); +const path = require("path"); + +const uploadDir = path.join(process.cwd(), "public", "uploads"); + +fs.existsSync(uploadDir) || fs.mkdirSync(uploadDir, { recursive: true }); + +strapi().start(); diff --git a/packages/nodejs/process.yml b/packages/nodejs/ecosystem.config.yml similarity index 77% rename from packages/nodejs/process.yml rename to packages/nodejs/ecosystem.config.yml index 79e9e0b..1b71e4d 100644 --- a/packages/nodejs/process.yml +++ b/packages/nodejs/ecosystem.config.yml @@ -1,8 +1,6 @@ apps: - cwd: /usr/local/src - script: node_modules/@strapi/strapi/bin/strapi.js - args: - - start + script: bin/app.js env: STRAPI_DISABLE_UPDATE_NOTIFICATION: 'true' STRAPI_HIDE_STARTUP_MESSAGE: 'true' @@ -10,6 +8,7 @@ apps: BROWSER: 'false' watch: false instances: 1 + source_map_support: true exec_mode: cluster name: app