FROM node:8.16.0-alpine as builder

ENV NODE_ENV dev

ENV NODE_ENV prod

RUN apk add --no-cache git
ARG var_env
ENV ambiente=$var_env

COPY . /user/app

WORKDIR /user/app

RUN yarn install
RUN npm rebuild node-sass

RUN chmod u+x scripts/config-env.sh
RUN ash scripts/config-env.sh

FROM nginx:1.15.0-alpine
ARG var_env

COPY --from=builder /user/app/dist/ /usr/share/nginx/html/
RUN apk add -U tzdata
RUN cp /usr/share/zoneinfo/Brazil/East /etc/localtime
RUN rm -f /etc/nginx/conf.d/default.conf
COPY scripts/portal.conf /etc/nginx/conf.d/
