From abe1f54aabc78123916c2ffb97b33e767ad5e4d7 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Sun, 15 Oct 2023 23:58:04 +0100 Subject: [PATCH] remove nginx and pm2 --- Dockerfile.standalone-infisical | 16 +++++------- backend/src/index.ts | 6 ++--- ecosystem.config.js | 21 ---------------- nginx/default-stand-alone-docker.conf | 36 --------------------------- 4 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 ecosystem.config.js delete mode 100644 nginx/default-stand-alone-docker.conf diff --git a/Dockerfile.standalone-infisical b/Dockerfile.standalone-infisical index 51774dae..00838bd8 100644 --- a/Dockerfile.standalone-infisical +++ b/Dockerfile.standalone-infisical @@ -94,22 +94,18 @@ FROM base AS production WORKDIR / -# Install PM2 -RUN npm install -g pm2 -# Copy ecosystem.config.js -COPY ecosystem.config.js . - -RUN apk add --no-cache nginx - -COPY nginx/default-stand-alone-docker.conf /etc/nginx/nginx.conf - COPY --from=backend-runner /app /backend COPY --from=frontend-runner /app ./backend/frontend-build EXPOSE 80 + +ENV PORT 80 ENV HTTPS_ENABLED false +ENV NODE_ENV production + +WORKDIR /backend -CMD ["pm2-runtime", "start", "ecosystem.config.js"] +CMD ["node", "build/index.js"] diff --git a/backend/src/index.ts b/backend/src/index.ts index 4ea684f3..74653658 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -90,8 +90,6 @@ const SmeeClient = require("smee-client"); // eslint-disable-line import path from "path"; import next from "next"; -const dir = path.join(__dirname, "../frontend-build"); - const main = async () => { await setup(); @@ -213,12 +211,14 @@ const main = async () => { // server status app.use("/api", healthCheck); - if (process.env.NODE_ENV === "production") { + if (process.env.NODE_ENV == "production") { + const dir = path.join(__dirname, "../frontend-build"); process.chdir(dir); const nextApp = next({ dev: false, dir }); + const nextHandler = nextApp.getRequestHandler(); await nextApp.prepare(); diff --git a/ecosystem.config.js b/ecosystem.config.js deleted file mode 100644 index d2bb79c4..00000000 --- a/ecosystem.config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - apps: [ - { - name: "backend", - script: "npm", - args: "run start", - cwd: "./backend", - instances: 1, - exec_mode: "fork", - autorestart: true, - watch: false, - max_memory_restart: "500M", - }, - { - name: "nginx", - script: "nginx", - args: "-g 'daemon off;'", - exec_interpreter: "none", - }, - ], -}; diff --git a/nginx/default-stand-alone-docker.conf b/nginx/default-stand-alone-docker.conf deleted file mode 100644 index b40e0fb1..00000000 --- a/nginx/default-stand-alone-docker.conf +++ /dev/null @@ -1,36 +0,0 @@ -events {} -http { - server { - listen 80; - - location /api { - proxy_set_header X-Real-RIP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - - proxy_set_header Host $http_host; - proxy_set_header X-NginX-Proxy true; - - proxy_pass http://localhost:4000; # for backend - proxy_redirect off; - - # proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict"; - proxy_cookie_path / "/; HttpOnly; SameSite=strict"; - } - - location / { - include /etc/nginx/mime.types; - - proxy_set_header X-Real-RIP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - - proxy_set_header Host $http_host; - proxy_set_header X-NginX-Proxy true; - - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - - proxy_pass http://localhost:3000; # for frontend - proxy_redirect off; - } - } -} \ No newline at end of file