FROM 10.65.133.229:8091/node:14 as builder

WORKDIR /usr/src/app

COPY . .
COPY .yarnrc.pgs2 .yarnrc

RUN sed -i 's#http://nexus.gosuslugi.local/content/groups/group-npm/#http://10.65.133.229:8081/repository/npm-group/#' yarn.lock \
&& sed -i 's#https://registry.yarnpkg.com/#http://10.65.133.229:8081/repository/npm/#' yarn.lock \
&& sed -i 's#https://nexus.devsun.ru/repository/npm-private/#http://10.65.133.229:8081/repository/npm_devsun/#' yarn.lock \
&& sed -i 's#https://registry.npmjs.org/#http://10.65.133.229:8081/repository/npm/#' yarn.lock \
&& yarn --update-checksums

RUN echo "PUBLIC_PATH=$PUBLIC_PATH" > .env \
    && yarn install \
    && yarn build

FROM 10.65.133.229:8091/pgs2-dev/nginx:2024-02-09

COPY --from=builder /usr/src/app/dist /usr/share/nginx/html

COPY ./conf/nginx.conf /etc/nginx/nginx.conf
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf
COPY ./app.config.json /usr/share/nginx/html/healthsx
COPY ./entrypoint.sh /usr/share/nginx/

RUN mkdir -p /usr/share/nginx/html/conf/ \
    && chmod 777 -R /usr/share/nginx/entrypoint.sh

ENTRYPOINT ["/usr/share/nginx/entrypoint.sh"]

EXPOSE 80

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

