# ================================
# Create image to build project
FROM node:12-alpine as builder

WORKDIR /ota-admin-portal
COPY . .
COPY .env.template ./.env

# Install the dependencies and make the folder
RUN npm install

# Build the project and copy the files
RUN npm run build

# ================================
# Create image to serve react app
FROM nginx:latest

#!/bin/sh

COPY ./nginx.conf /etc/nginx/nginx.conf

## Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*

# Copy from the stahg 1
COPY --from=builder /ota-admin-portal/build /usr/share/nginx/html

EXPOSE 80 443 8080

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