Skip to content

Instantly share code, notes, and snippets.

@justindavies
Created August 24, 2018 11:21
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 justindavies/c61564de4e52eb211ae0bd45bde81e01 to your computer and use it in GitHub Desktop.
Save justindavies/c61564de4e52eb211ae0bd45bde81e01 to your computer and use it in GitHub Desktop.
# build environment
FROM node as builder
ARG REACT_APP_SHA
ENV REACT_APP_SHA=${REACT_APP_SHA}
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN npm install -g -s --no-progress yarn
RUN yarn add react-scripts -g
COPY . /usr/src/app
RUN yarn build
# production environment
FROM nginx:1.13.9-alpine
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
# Fix NGINX config for React
#RUN sed -ie 's/index index.html index.htm;/try_files $uri $uri\/ \/index.html;/g' /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
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