FROM node:16 as builder

COPY . ./
RUN yarn
RUN yarn build

FROM nginx:1.24-alpine-slim

COPY ./conf/nginx.conf /etc/nginx/nginx.conf
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder ./dist /usr/share/nginx/html
COPY ./app.config.json /usr/share/nginx/html/healthsx
RUN mkdir -p /usr/share/nginx/html/conf/

COPY ./entrypoint.sh /usr/share/nginx/
RUN chmod 777 -R /usr/share/nginx/entrypoint.sh
ENTRYPOINT ["/usr/share/nginx/entrypoint.sh"]

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
