FROM node:16-alpine as builder
WORKDIR /app
COPY . .
RUN apk add g++ make python3 git zlib
RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build:keck

FROM node:16-alpine as node_modules
WORKDIR /app
COPY --from=builder /app/dist/apps/keck .
COPY --from=builder /app/apps/keck/package.prod.json ./package.json
RUN npm i

# =============
# keck image
# =============
FROM node:16-alpine as keck
WORKDIR /app
COPY --from=node_modules /app .

ENV FIREBASE_ACCOUNT=
ENV FIREBASE_CERT=
ENV FIREBASE_PROJECT=
ENV HOST=0.0.0.0
ENV PORT=3000

# coding
ENV TZ 'Asia/Shanghai'
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

EXPOSE 3000
CMD ["node", "main.js"]