### STAGE 1: Build  ----------------------------------------------------------------------------------------------------
    ### STAGE 1: Build  ----------------------------------------------------------------------------------------------------
FROM node:18

ARG VERSION
ARG BUILD
ARG TARGETENV
ARG CURLOPT_SSL_VERIFYPEER=FALSE

LABEL version=$VERSION build=$BUILD mode=$TARGETENV
EXPOSE 80
RUN apt-get update && apt-get install -y curl ca-certificates
RUN apt-get install -y nginx
RUN rm -rf /usr/share/nginx/html/
RUN mkdir -p /usr/share/nginx/html
WORKDIR /data

COPY package.json package-lock.json ./


ARG VERSION
ARG BUILD
ARG TARGETENV
ARG CURLOPT_SSL_VERIFYPEER=FALSE
RUN npm install

COPY . .

RUN npm run build

# служебные штуки
RUN cp -R /data/dist/* /usr/share/nginx/html
COPY nginx.conf /etc/nginx/sites-enabled/default
RUN chmod +x /data/run.sh

CMD ["/data/run.sh"]
    