2023-02-22 12:38:30 +08:00
|
|
|
###### [STAGE] Build ######
|
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
|
|
|
|
|
2023-02-22 12:38:30 +08:00
|
|
|
# No need for Docker build
|
2022-12-22 23:16:10 +08:00
|
|
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
|
|
|
2023-02-22 12:38:30 +08:00
|
|
|
### Install toolchain ###
|
2023-03-30 18:51:20 +08:00
|
|
|
RUN npm add --location=global pnpm@^8.0.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 . .
|
|
|
|
|
2023-02-22 12:38:30 +08:00
|
|
|
### Install dependencies and build ###
|
2023-02-15 17:02:59 +08:00
|
|
|
RUN node .scripts/update-parcelrc.js
|
2022-06-23 19:17:02 +08:00
|
|
|
RUN pnpm i
|
2022-10-17 19:37:59 +08:00
|
|
|
RUN pnpm -r build
|
2022-06-23 19:17:02 +08:00
|
|
|
|
2023-02-22 12:38:30 +08:00
|
|
|
### Add official connectors ###
|
2023-03-15 17:41:18 +08:00
|
|
|
ARG additional_connector_args
|
|
|
|
ENV ADDITIONAL_CONNECTOR_ARGS=${additional_connector_args}
|
2023-04-02 14:12:30 +08:00
|
|
|
RUN pnpm cli connector link $ADDITIONAL_CONNECTOR_ARGS -p .
|
2022-09-05 18:52:57 +08:00
|
|
|
|
2023-02-22 12:38:30 +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
|
|
|
|
|
2023-02-22 12:38:30 +08:00
|
|
|
### Clean up ###
|
|
|
|
RUN rm -rf .scripts .parcel-cache pnpm-*.yaml packages/cloud
|
2022-06-23 19:17:02 +08:00
|
|
|
|
2023-02-22 12:38:30 +08:00
|
|
|
###### [STAGE] Seal ######
|
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"]
|