Last active
December 28, 2023 20:42
-
-
Save gmoreiraGP/a625054ece62711acdfdc1c53e77d207 to your computer and use it in GitHub Desktop.
NGINX - Mongo DB - ExpressJS - NextJS
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.8" | |
| services: | |
| nginx: | |
| image: nginx:latest | |
| container_name: nginx | |
| volumes: | |
| - ./nginx/nginx.conf:/etc/nginx/nginx.conf | |
| depends_on: | |
| - mongo | |
| - api | |
| - frontend | |
| ports: | |
| - "8080:80" | |
| environment: | |
| - NGINX_PORT=80 | |
| mongo: | |
| image: mongo | |
| container_name: mongo | |
| restart: always | |
| environment: | |
| MONGO_INITDB_ROOT_USERNAME: root | |
| MONGO_INITDB_ROOT_PASSWORD: root | |
| ports: | |
| - "27017:27017" | |
| api: | |
| build: ./api | |
| container_name: api | |
| volumes: | |
| - ./api/:/var/www/api | |
| depends_on: | |
| - mongo | |
| ports: | |
| - "1337:1337" | |
| command: yarn run dev | |
| frontend: | |
| build: ./frontend | |
| container_name: frontend | |
| volumes: | |
| - ./frontend/:/var/www/frontend | |
| depends_on: | |
| - mongo | |
| - api | |
| ports: | |
| - "3000:3000" | |
| command: yarn run 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
| # pull the Node.js Docker image | |
| FROM node:alpine | |
| # create the directory inside the container | |
| WORKDIR /var/www/api | |
| # copy the package.json files from local machine to the workdir in container | |
| COPY package*.json ./ | |
| # run npm install in our local machine | |
| RUN npm config set proxy http://proxy.policiamilitar.sp.gov.br:3128 | |
| # run npm install in our local machine | |
| RUN npm install | |
| # copy the generated modules and all other files to the container | |
| COPY . . | |
| # our app is running on port 3000 within the container, so need to expose it | |
| EXPOSE 1337 | |
| # the command that starts our app | |
| CMD ["npm", "run", "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
| # pull the Node.js Docker image | |
| FROM node:alpine | |
| # create the directory inside the container | |
| WORKDIR /var/www/frontend | |
| # copy the package.json files from local machine to the workdir in container | |
| COPY package*.json ./ | |
| # run npm install in our local machine | |
| RUN npm install | |
| # copy the generated modules and all other files to the container | |
| COPY . . | |
| # our app is running on port 3000 within the container, so need to expose it | |
| EXPOSE 3000 | |
| # the command that starts our app | |
| CMD ["npm", "run", "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
| user www-data; | |
| worker_processes auto; | |
| pid /run/nginx.pid; | |
| include /etc/nginx/modules-enabled/*.conf; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| server { | |
| listen 80; | |
| server_name localhost 127.0.0.1; | |
| location / { | |
| proxy_pass http://frontend:3000; | |
| proxy_set_header X-Forwarded-For $remote_addr; | |
| } | |
| location /api { | |
| proxy_pass http://api:1337/; | |
| proxy_set_header X-Forwarded-For $remote_addr; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment