Code Monkey home page Code Monkey logo

nextjs-docker-pm2-nginx's Introduction

Next.js with Docker, PM2 and NGINX

This project is a production Docker setup for a Next.js app.

The Next.js app is launched with PM2 Runtime, which is a Production Process Manager for Node.js applications and is used to keep the app alive forever.

A second container with the NGINX web server is used as a reverse proxy, and to handle HTTP caching.

Docker Compose

docker-compose up

NGINX listens on port 80, which is the default HTTP port, so you can just visit http://localhost/

Without Docker Compose

# Build images
docker build --tag nextjs-image .
docker build --tag nginx-image ./nginx

# Create shared network
docker network create my-network

# Run containers
docker run --network my-network --name nextjs-container nextjs-image
docker run --network my-network --link nextjs-container:nextjs --publish 80:80 nginx-image

Next.js container is referenced inside NGINX container as nextjs.

PM2 commands

PM2 commands can still be used inside a container with the docker exec command:

docker exec -it <container-id> pm2 monit          # Monitoring CPU/Usage of each process
docker exec -it <container-id> pm2 list           # Listing managed processes
docker exec -it <container-id> pm2 show           # Get more information about a process
docker exec -it <container-id> pm2 reload all     # 0sec downtime reload all applications

nextjs-docker-pm2-nginx's People

Contributors

steveholgado avatar

Watchers

James Cloos 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.