2023-05-06 14:29:59 +03:00
|
|
|
# BUILD ENVIRONMENT
|
2022-12-29 23:09:44 +02:00
|
|
|
FROM node:14-slim as builder
|
2020-12-26 02:27:53 +02:00
|
|
|
WORKDIR /app
|
|
|
|
|
2023-05-06 14:29:59 +03:00
|
|
|
ARG APP_SUBFOLDER=""
|
2023-05-06 12:22:00 +03:00
|
|
|
|
2022-05-09 03:03:00 +03:00
|
|
|
COPY .npmrc .npmrc
|
2020-12-26 02:27:53 +02:00
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm install
|
2022-05-09 03:03:00 +03:00
|
|
|
RUN rm -f .npmrc
|
2020-12-26 02:27:53 +02:00
|
|
|
|
|
|
|
COPY . ./
|
2023-05-06 12:22:00 +03:00
|
|
|
|
|
|
|
# build the react app
|
2023-05-06 14:29:59 +03:00
|
|
|
RUN if [ -z "$APP_SUBFOLDER" ]; then npm run build; else PUBLIC_URL=/${APP_SUBFOLDER}/ npm run build; fi
|
2020-12-26 02:27:53 +02:00
|
|
|
|
2023-05-06 14:29:59 +03:00
|
|
|
# PRODUCTION ENVIRONMENT
|
2022-12-29 23:09:44 +02:00
|
|
|
FROM node:14-slim
|
2020-12-26 02:27:53 +02:00
|
|
|
|
2023-05-06 14:29:59 +03:00
|
|
|
ARG APP_SUBFOLDER=""
|
|
|
|
|
|
|
|
RUN printf '\n\n- Copy application files\n'
|
2020-12-26 02:27:53 +02:00
|
|
|
COPY --from=builder /app/build ./application/${APP_SUBFOLDER}
|
|
|
|
COPY --from=builder /app/build/index.html ./application/
|
2023-05-06 12:22:00 +03:00
|
|
|
COPY --from=builder /app/setenv.js ./application/setenv.js
|
2020-12-26 02:27:53 +02:00
|
|
|
|
|
|
|
#install static server
|
|
|
|
RUN npm install -g serve
|
|
|
|
|
2022-12-29 22:47:15 +02:00
|
|
|
# environment variables
|
|
|
|
ENV AUTHOR="Tudor Stanciu"
|
2023-05-06 14:29:59 +03:00
|
|
|
ENV PUBLIC_URL=/${APP_SUBFOLDER}/
|
2022-12-29 22:47:15 +02:00
|
|
|
ARG APP_VERSION=0.0.0
|
|
|
|
ENV APP_VERSION=${APP_VERSION}
|
|
|
|
|
2023-03-27 02:15:22 +03:00
|
|
|
ARG APP_DATE="-"
|
|
|
|
ENV APP_DATE=${APP_DATE}
|
|
|
|
|
2020-12-26 02:27:53 +02:00
|
|
|
#set workdir to root
|
|
|
|
WORKDIR /
|
|
|
|
|
|
|
|
EXPOSE 80
|
|
|
|
|
2023-05-06 14:29:59 +03:00
|
|
|
CMD ["sh", "-c", "node application/setenv.js && serve -s application -p 80"]
|