41 lines
1.1 KiB
Docker
41 lines
1.1 KiB
Docker
# Stage 1 - the build process
|
|
FROM node:18 as builder
|
|
RUN mkdir /usr/src/app
|
|
WORKDIR /usr/src/app
|
|
ENV PATH /usr/src/app/node_modules/.bin:$PATH
|
|
ARG REACT_APP_PATH
|
|
ARG REACT_APP_DOMAIN
|
|
ARG REACT_APP_IMG_PATH
|
|
ARG REACT_APP_PUBLIC
|
|
ARG PUBLIC_URL
|
|
ARG GENERATE_SOURCEMAP
|
|
ENV REACT_APP_API $REACT_APP_DOMAIN/$REACT_APP_PATH
|
|
ENV REACT_APP_IMG_URL $REACT_APP_DOMAIN/$REACT_APP_IMG_PATH
|
|
RUN echo "DEBUG": $PUBLIC_URL
|
|
|
|
# Copy package.json and yarn.lock files first to leverage Docker cache
|
|
COPY package.json yarn.lock /usr/src/app/
|
|
RUN yarn install # Install dependencies
|
|
|
|
# Copy the rest of your application
|
|
COPY . /usr/src/app
|
|
|
|
# Build the app
|
|
RUN yarn build
|
|
|
|
# Stage 2 - the production environment
|
|
FROM nginx:1.13.9-alpine
|
|
|
|
# Clean existing configuration and copy new one
|
|
RUN rm -rf /etc/nginx/conf.d
|
|
COPY conf /etc/nginx
|
|
|
|
# Clear the default content in the nginx folder
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copy the build folder from the builder stage to Nginx's public folder
|
|
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
|
|
|
|
# Run Nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|