-
-
Save EdsonAlcala/75bd5f65c9aa8006cbded6a4d8e5d71e to your computer and use it in GitHub Desktop.
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
# if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/ | |
FROM node:8 as builder | |
RUN mkdir -p /opt/app | |
# set our node environment, either development or production | |
# defaults to production, compose overrides this to development on build and run | |
ARG NODE_ENV=production | |
ENV NODE_ENV $NODE_ENV | |
ARG REACT_APP_BASEURL=%REACT_APP_BASEURL% | |
ENV REACT_APP_BASEURL $REACT_APP_BASEURL | |
# default to port 80 for node, and 5858 or 9229 for debug | |
ARG PORT=8080 | |
ENV PORT $PORT | |
EXPOSE $PORT 5858 9229 | |
# install app dependencies first, in a different location for easier app bind mounting for local development | |
WORKDIR /opt | |
COPY package.json package-lock.json* ./ | |
RUN npm install && npm cache clean --force | |
ENV PATH /opt/node_modules/.bin:$PATH | |
# copy in our source code last, as it changes the most | |
WORKDIR /opt/app | |
COPY . /opt/app | |
# if you want to use npm start instead, then use `docker run --init in production` | |
# so that signals are passed properly. Note the code in index.js is needed to catch Docker signals | |
# using node here is still more graceful stopping then npm with --init afaik | |
# I still can't come up with a good production way to run with npm and graceful shutdown | |
RUN [ "npm", "run", "build" ] | |
FROM nginx:1-alpine | |
WORKDIR /var/www/app | |
ARG REACT_APP_BASEURL=http://localhost:3000 | |
ENV REACT_APP_BASEURL $REACT_APP_BASEURL | |
EXPOSE 8080 | |
COPY --from=builder /opt/app/build . | |
COPY entrypoint.sh /opt/entrypoint.sh | |
ENTRYPOINT ["sh", "/opt/entrypoint.sh"] | |
COPY webapp.conf /etc/nginx/conf.d/default.conf | |
CMD ["nginx-fe"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment