# get the base node image
FROM node:14 as builder

# set the working dir for container
WORKDIR /frontend

# copy the json file first
COPY ./package.json /frontend
COPY ./package-lock.json /frontend


# install npm dependencies
RUN npm install

# copy other project files
COPY . .

# build the folder
RUN npm run build
CMD ["./start.sh"]

# Handle Nginx
FROM nginx
COPY --from=builder /frontend/build /usr/share/nginx/html
COPY ./etc/nginx.conf /etc/nginx/conf.d/default.conf