Skip to content

rsandagon/docker-react-app-template

Repository files navigation

Docker React Template

Setup

  1. Install Docker and docker-compose.
  2. Run docker-compose up -d --build. This will build the environment.

Dev

  1. Spin the container, docker-compose start
  2. To stop, docker-compose stop
  3. To restart, docker-compose start
  4. To remove the container, docker-compose down

Production

  1. Fire up the container, docker-compose -f docker-compose-prod.yml up -d --build
  2. To stop, docker-compose stop
  3. To restart, docker-compose start
  4. To remove the container, docker-compose down

React Router and Nginx

If you are using react router and nginx,

  1. Change the default nginx config:
RUN rm -rf /etc/nginx/conf.d
COPY conf /etc/nginx
  1. Use the file Dockerfile-prod-with-react-router
  2. Create the following folder structures along with the default.conf file:
└── conf
    └── conf.d
        └── default.conf

default.conf:

server {
  listen 80;
  location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri $uri/ /index.html;
  }
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
    root   /usr/share/nginx/html;
  }
}

Deploy

How to deploy to AWS

This project was bootstrapped with Create React App

with the help from M. Herman's article

About

dockerize react!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published