FROM node:18.17-alpine as builder
RUN apk add --no-cache git
WORKDIR /app
COPY . .
RUN yarn install
RUN yarn build
FROM node:18.17-alpine
ARG env_target
WORKDIR /app
RUN echo ${env_target}
COPY env/$env_target /app/.env
COPY --from=builder /app/env/$env_target .env
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/assets ./assets
COPY --from=builder /app/package.json ./package.json
CMD ["node", "--max-old-space-size=8192","--max-http-header-size", "512000", "-r", "dotenv/config", "dist/main"]