# get the base node image
FROM repo.ayeneh.co/dockerhub/node:alpine as builder

# set the working dir for container
WORKDIR /app

RUN apk update && apk add git
# copy the json file first
COPY ./package.json /app

# RUN npm config set registry https://repo.ayeneh.co/artifactory/npm/
# install npm dependencies
RUN npm install

# copy other project files
COPY . .

# build the folder
RUN npm run build

# Handle Nginx
FROM repo.ayeneh.co/dockerhub/nginx
COPY --from=builder /app/dist /usr/share/nginx/html
COPY ./nginx/empty.html /usr/share/nginx/html/empty.html
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
