Skip to content

Instantly share code, notes, and snippets.

@nileshgulia1
Created July 16, 2019 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nileshgulia1/2ba77fa3ca573fc74ac46622f1ae260f to your computer and use it in GitHub Desktop.
Save nileshgulia1/2ba77fa3ca573fc74ac46622f1ae260f to your computer and use it in GitHub Desktop.
Docker
version: '3.7'
services:
server:
build: ./server
expose:
- 3001
environment:
USER_NAME: ${USER_NAME}
PASSWORD: ${PASSWORD}
ports:
- '3001:3001'
volumes:
- './server:/app'
- '/app/node_modules'
environment:
- NODE_ENV=development
command: yarn start:server
client:
build: ./
expose:
- 3000
ports:
- '3000:3000'
volumes:
- '.:/app'
- '/app/node_modules'
environment:
- NODE_ENV=development
links:
- server
command: yarn start
# base image
FROM node:12.2.0-alpine
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
COPY . /app/
RUN npm install --silent
RUN npm run build
RUN npm install -g serve
CMD serve -s build
RUN npm install react-scripts@3.0.1 -g --silent
# start app
CMD ["npm", "start"]
# base image
FROM node:12.2.0-alpine
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/
RUN npm install
COPY . /app/
# start app
CMD ["npm", "run", "start:server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment