Skip to content

Instantly share code, notes, and snippets.

@sen0rxol0
Last active October 16, 2018 16:31
Show Gist options
  • Save sen0rxol0/488c76b669cc783d3369050bed041d4f to your computer and use it in GitHub Desktop.
Save sen0rxol0/488c76b669cc783d3369050bed041d4f to your computer and use it in GitHub Desktop.
React.js server dockerfile basic
version: '3.5'
services:
app:
build: .
volumes:
- '.:/app'
ports:
- '3000:80'
environment:
- NODE_ENV=development
## Build environment ##
FROM node as builder
# Create app directory
RUN mkdir -p /app
WORKDIR /app
# Install app dependencies
COPY package.json /app
COPY yarn.lock /app
RUN yarn
# Bundle app source
COPY . /app
RUN yarn build
## production environment ##
FROM nginx:1.15.0-alpine
# Copy Nginx conf
RUN rm -rf /etc/nginx/conf.d
COPY conf /etc/nginx
# Copy react code
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment