Skip to content

Instantly share code, notes, and snippets.

@canavci2016
Last active August 25, 2022 20:46
Show Gist options
  • Save canavci2016/00176773e4ff90eff7393479cfaf5562 to your computer and use it in GitHub Desktop.
Save canavci2016/00176773e4ff90eff7393479cfaf5562 to your computer and use it in GitHub Desktop.
node-ngnix full setup on docker
version: "3.0"
services:
my-node:
image: cv-maker-node:16
build:
context: .
dockerfile: Dockerfile
args:
NODE_VERSION: "16-alpine3.15"
command: node src/app.js
environment:
- PORT=4000
env_file:
- ./api/.env
ports:
- "4001:4000"
volumes:
- .:/usr/src/app
networks:
- nginx-node
my-nginx:
image: nginx:latest
volumes:
- ./nginx.docker.default.conf.template:/etc/nginx/templates/default.conf.template
environment:
- NGINX_PORT=8082
ports:
- "80:8082"
depends_on:
- my-node
networks:
- nginx-node
networks:
nginx-node:
ARG NODE_VERSION
FROM node:${NODE_VERSION}
ENV NODE_ENV=production
WORKDIR /usr/src/app
RUN mkdir -p /usr/src/app/api
RUN mkdir -p /usr/src/app/client
WORKDIR /usr/src/app/client
COPY ["./client/package.json", "./client/yarn.lock", "./"]
RUN yarn install
COPY ./client/ .
RUN yarn run build
WORKDIR /usr/src/app/api
COPY ./api/ ./
RUN npm ci --only=production --omit=dev
server {
listen ${NGINX_PORT};
server_name localhost;
location / {
proxy_pass http://my-node:4000;
}
}
@canavci2016
Copy link
Author

nodejs prod docker setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment