# Step 1: Build the app in image "builder"
FROM node:lts-alpine AS builder

COPY package.json package-lock.json ./
RUN npm i && mkdir /app && mv ./node_modules ./app
WORKDIR /app
COPY . .
RUN node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod

# Step 2: Use build output from 'builder'

FROM nginx:stable-alpine
LABEL version="1.0"

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

WORKDIR /usr/share/nginx/html
COPY --from=builder /app/dist/frontend-inversiones/ .