Last active
October 16, 2018 16:31
-
-
Save sen0rxol0/488c76b669cc783d3369050bed041d4f to your computer and use it in GitHub Desktop.
React.js server dockerfile basic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
services: | |
app: | |
build: . | |
volumes: | |
- '.:/app' | |
ports: | |
- '3000:80' | |
environment: | |
- NODE_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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