FROM public.ecr.aws/docker/library/node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
# npm install, not npm ci: package-lock.json is missing four packages that
# package.json declares (@tabler/icons-webfont, @tabler/icons, material-icons,
# posthog-js), so `npm ci` refuses to run. setup.sh and setup.bat both use
# `npm install --legacy-peer-deps` for every frontend - match them.
RUN npm install --legacy-peer-deps
COPY . .
RUN npx ng build --configuration=docker

FROM public.ecr.aws/docker/library/nginx:alpine
COPY --from=build /app/dist/gmarket/browser /usr/share/nginx/html
COPY docker/nginx-spa.conf /etc/nginx/conf.d/default.conf
# assets/env.js carries the runtime config that cannot live in environment.*.ts
# (those are compiled into the bundle). It is generated at start-up from
# MICROFE_HOST so one image serves every tier - see docker/spa-entrypoint.sh.
COPY docker/spa-entrypoint.sh /usr/local/bin/spa-entrypoint.sh
RUN chmod +x /usr/local/bin/spa-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/spa-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80
