Giter Site home page Giter Site logo

guilospanck / node-and-nginx-with-docker-compose Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 139 KB

This repository will serve as a guideline if you want to have a server running NGINX and Node.js with Docker.

JavaScript 11.79% Dockerfile 0.88% TypeScript 87.32%
docker docker-compose nginx nodejs

node-and-nginx-with-docker-compose's Introduction

Node and NGINX with Docker Compose

This repository will serve as a guideline if you want to have a server running NGINX and Node.js with Docker.

Installation and How To Use

Clone the repository:

git clone https://github.com/Guilospanck/NodeAndNginxWithDockerCompose

Install Docker;

Install Docker Compose;

Inside the project's folder, run docker-compose command:

docker-compose up -d --build
  • -d to run in detach mode
  • --build to build images before starting containers

➡️ REMEMBER TO:

If you are using a linux (like Ubuntu) machine in AWS EC2, be aware of UFW (Uncomplicated Firewall):

  • OR DO NOT ENABLE UFW
  • OR ENABLE IT WITH SSH TOO, OTHERWISE YOU WON'T BE ABLE TO SSH AFTER CONNECTION IS TERMINATED.

If you are using ENV variables:

Remember to set in the docker-compose.yml file, because you're going to need to define which NODE_ENV is going to be used. So, you can do something like this:

FROM node:14.17.3-alpine

WORKDIR /build
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN yarn build

FROM node:14.17.3-alpine

WORKDIR /app
COPY package.json yarn.lock .env.production .sequelizerc newrelic.js package.json ./
RUN yarn install --production --frozen-lockfile
COPY --from=build /build/dist ./

CMD ["node", "main.js"]   <-- Here you would need something like NODE_ENV=production node main.js, but you're going to set it in the docker-compose file
version: "3"

services:
   api:
       container_name: api
       restart: unless-stopped
       build:
           context: ./app
       ports:
           - 4444
       environment:
           - NODE_ENV=production # <---- HERE!
       networks: # Obs.: docker compose already creates a default network. So it isn't needed if you don't want to
           - api
       
   nginx:
       container_name: nginx
       restart: unless-stopped
       build:
           context: ./nginx
       ports:
           - 80:80
       depends_on:
           - api
       networks:
           - api

networks:
   api:
       driver: bridge

node-and-nginx-with-docker-compose's People

Contributors

guilospanck avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.