47 lines
974 B
Plaintext
47 lines
974 B
Plaintext
# build environment
|
|
FROM node:14-slim as builder
|
|
WORKDIR /app
|
|
|
|
# global args
|
|
ARG APP_SUBFOLDER=
|
|
|
|
COPY .npmrc .npmrc
|
|
COPY package*.json ./
|
|
RUN npm install
|
|
RUN rm -f .npmrc
|
|
|
|
COPY . ./
|
|
|
|
# set the PUBLIC_URL environment variable
|
|
ENV PUBLIC_URL /${APP_SUBFOLDER}/
|
|
|
|
# build the react app
|
|
# RUN npm run build
|
|
RUN if [ -z "$APP_SUBFOLDER" ]; then npm run build; else PUBLIC_URL=$PUBLIC_URL npm run build; fi
|
|
|
|
|
|
# production environment
|
|
FROM node:14-slim
|
|
RUN printf '\n\n- Copy application files\n'
|
|
|
|
COPY --from=builder /app/build ./application/${APP_SUBFOLDER}
|
|
COPY --from=builder /app/build/index.html ./application/
|
|
COPY --from=builder /app/setenv.js ./application/setenv.js
|
|
|
|
#install static server
|
|
RUN npm install -g serve
|
|
|
|
# environment variables
|
|
ENV AUTHOR="Tudor Stanciu"
|
|
ARG APP_VERSION=0.0.0
|
|
ENV APP_VERSION=${APP_VERSION}
|
|
|
|
ARG APP_DATE="-"
|
|
ENV APP_DATE=${APP_DATE}
|
|
|
|
#set workdir to root
|
|
WORKDIR /
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["sh", "-c", "node setenv.js && serve -s application -p 80"] |