FROM node:18-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
RUN npm install -g pnpm@9.3.0
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
ARG APP_TITLE=成都网讯MaaS底座
ARG ENABLE_PLAYGROUND=true
ENV APP_TITLE=$APP_TITLE
ENV ENABLE_PLAYGROUND=$ENABLE_PLAYGROUND
RUN pnpm build

FROM nginx:alpine
RUN apk add --no-cache gettext
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf.template /etc/nginx/conf.d/default.conf.template
COPY docker-entrypoint.sh /docker-entrypoint.d/99-envsubst.sh
RUN chmod +x /docker-entrypoint.d/99-envsubst.sh
EXPOSE 80
