2022-06-23 19:17:02 +08:00
|
|
|
# Build stage
|
2023-01-03 15:39:58 +08:00
|
|
|
FROM node:18-alpine as builder
|
2022-06-23 19:17:02 +08:00
|
|
|
WORKDIR /etc/logto
|
|
|
|
ENV CI=true
|
|
|
|
|
2022-12-22 23:16:10 +08:00
|
|
|
# No need for build
|
|
|
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
|
|
|
2022-06-23 19:17:02 +08:00
|
|
|
# Install toolchain
|
2022-11-07 19:28:34 +08:00
|
|
|
RUN npm add --location=global pnpm@^7.14.0
|
2022-06-23 19:17:02 +08:00
|
|
|
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine
|
|
|
|
RUN apk add --no-cache python3 make g++
|
|
|
|
|
2022-11-07 19:28:34 +08:00
|
|
|
COPY . .
|
|
|
|
|
2022-06-23 19:17:02 +08:00
|
|
|
# Install dependencies and build
|
|
|
|
RUN pnpm i
|
2022-10-17 19:37:59 +08:00
|
|
|
RUN pnpm -r build
|
2022-06-23 19:17:02 +08:00
|
|
|
|
2022-09-05 18:52:57 +08:00
|
|
|
# Add official connectors
|
2022-10-19 11:35:39 +08:00
|
|
|
RUN pnpm cli connector add --official -p .
|
2022-09-05 18:52:57 +08:00
|
|
|
|
2022-06-23 19:17:02 +08:00
|
|
|
# Prune dependencies for production
|
2022-12-14 13:23:59 +08:00
|
|
|
RUN rm -rf node_modules packages/**/node_modules
|
2022-06-23 19:17:02 +08:00
|
|
|
RUN NODE_ENV=production pnpm i
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
RUN rm -rf .parcel-cache pnpm-*.yaml
|
|
|
|
|
|
|
|
# Seal stage
|
2023-01-03 15:39:58 +08:00
|
|
|
FROM node:18-alpine as app
|
2022-06-23 19:17:02 +08:00
|
|
|
WORKDIR /etc/logto
|
|
|
|
COPY --from=builder /etc/logto .
|
|
|
|
EXPOSE 3001
|
|
|
|
ENTRYPOINT ["npm", "start"]
|