Skip to content

Instantly share code, notes, and snippets.

@mohamednizar
Created October 3, 2018 11:19
Show Gist options
  • Save mohamednizar/4e2d3d2ea2a9b5acea04eecf035ff71d to your computer and use it in GitHub Desktop.
Save mohamednizar/4e2d3d2ea2a9b5acea04eecf035ff71d to your computer and use it in GitHub Desktop.
Dockerize React Project
# ./docker-compose.yml
version: '2'
web:
build: ./app
hostname: www
domainname: sleas.dev
volumes:
- './app/node_modules:/usr/app/node_modules'
- './app/src:/usr/app/src'
- './app/public:/usr/app/public'
ports:
- 3000:3000
environment:
- NODE_ENV=development
# base image
FROM node:9.6.1
# set working directory
RUN mkdir /usr/app
WORKDIR /usr/app
# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /usr/app/package.json
RUN npm install --silent
RUN npm install ngx -g --silent
RUN npm install react-scripts@1.1.1 -g --silent
# start app
CMD ["npm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment