2023-02-21 23:38:30 -05:00
|
|
|
###### [STAGE] Build ######
|
2023-01-03 02:39:58 -05:00
|
|
|
FROM node:18-alpine as builder
|
2022-06-23 06:17:02 -05:00
|
|
|
WORKDIR /etc/logto
|
|
|
|
ENV CI=true
|
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
# No need for Docker build
|
2022-12-22 10:16:10 -05:00
|
|
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Install toolchain ###
|
2022-11-07 06:28:34 -05:00
|
|
|
RUN npm add --location=global pnpm@^7.14.0
|
2022-06-23 06:17:02 -05: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 06:28:34 -05:00
|
|
|
COPY . .
|
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Install dependencies and build ###
|
2023-02-15 04:02:59 -05:00
|
|
|
RUN node .scripts/update-parcelrc.js
|
2022-06-23 06:17:02 -05:00
|
|
|
RUN pnpm i
|
2022-10-17 06:37:59 -05:00
|
|
|
RUN pnpm -r build
|
2022-06-23 06:17:02 -05:00
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Add official connectors ###
|
2022-10-18 22:35:39 -05:00
|
|
|
RUN pnpm cli connector add --official -p .
|
2022-09-05 05:52:57 -05:00
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Prune dependencies for production ###
|
2022-12-14 00:23:59 -05:00
|
|
|
RUN rm -rf node_modules packages/**/node_modules
|
2022-06-23 06:17:02 -05:00
|
|
|
RUN NODE_ENV=production pnpm i
|
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Clean up ###
|
|
|
|
RUN rm -rf .scripts .parcel-cache pnpm-*.yaml packages/cloud
|
2022-06-23 06:17:02 -05:00
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
###### [STAGE] Seal ######
|
2023-01-03 02:39:58 -05:00
|
|
|
FROM node:18-alpine as app
|
2022-06-23 06:17:02 -05:00
|
|
|
WORKDIR /etc/logto
|
|
|
|
COPY --from=builder /etc/logto .
|
|
|
|
EXPOSE 3001
|
|
|
|
ENTRYPOINT ["npm", "start"]
|