Last active
August 25, 2022 20:46
-
-
Save canavci2016/00176773e4ff90eff7393479cfaf5562 to your computer and use it in GitHub Desktop.
node-ngnix full setup on docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen ${NGINX_PORT}; | |
server_name localhost; | |
location / { | |
proxy_pass http://my-node:4000; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nodejs prod docker setup