Skip to content

Instantly share code, notes, and snippets.

@thinhbuzz
Created May 17, 2021 03:02
Show Gist options
  • Save thinhbuzz/26b2b8481711ee760b4fb5ee8645a1a0 to your computer and use it in GitHub Desktop.
Save thinhbuzz/26b2b8481711ee760b4fb5ee8645a1a0 to your computer and use it in GitHub Desktop.
build docker image for react application
FROM node:14-alpine3.10 AS builder
WORKDIR /usr/src/app
ARG API_ENDPOINT=http://localhost:3333/api
ENV REACT_APP_API_ENDPOINT=$API_ENDPOINT
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:1.20-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
EXPOSE 80
# Launch NGINX
CMD [ "nginx", "-g", "daemon off;" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment