2023-02-21 23:38:30 -05:00
|
|
|
###### [STAGE] Build ######
|
2023-12-26 10:14:36 -05:00
|
|
|
FROM node:20-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
|
2023-05-31 23:37:59 -05:00
|
|
|
ENV PUPPETEER_SKIP_DOWNLOAD=true
|
2022-12-22 10:16:10 -05:00
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Install toolchain ###
|
2024-05-09 03:42:31 -05:00
|
|
|
RUN npm add --location=global pnpm@^9.0.0
|
2022-06-23 06:17:02 -05:00
|
|
|
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine
|
2023-11-12 22:41:35 -05:00
|
|
|
RUN apk add --no-cache python3 make g++ rsync
|
2022-06-23 06:17:02 -05:00
|
|
|
|
2022-11-07 06:28:34 -05:00
|
|
|
COPY . .
|
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
### Install dependencies and build ###
|
2022-06-23 06:17:02 -05:00
|
|
|
RUN pnpm i
|
2023-04-19 05:05:43 -05:00
|
|
|
|
2023-09-22 02:45:34 -05:00
|
|
|
### Set if dev features enabled ###
|
|
|
|
ARG dev_features_enabled
|
|
|
|
ENV DEV_FEATURES_ENABLED=${dev_features_enabled}
|
|
|
|
|
2023-04-19 05:05:43 -05:00
|
|
|
ARG applicationinsights_connection_string
|
|
|
|
ENV APPLICATIONINSIGHTS_CONNECTION_STRING=${applicationinsights_connection_string}
|
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 ###
|
2023-03-15 04:41:18 -05:00
|
|
|
ARG additional_connector_args
|
|
|
|
ENV ADDITIONAL_CONNECTOR_ARGS=${additional_connector_args}
|
2023-04-02 01:12:30 -05:00
|
|
|
RUN pnpm cli connector link $ADDITIONAL_CONNECTOR_ARGS -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 ###
|
2024-07-24 00:52:44 -05:00
|
|
|
RUN rm -rf .scripts pnpm-*.yaml packages/cloud
|
2022-06-23 06:17:02 -05:00
|
|
|
|
2023-02-21 23:38:30 -05:00
|
|
|
###### [STAGE] Seal ######
|
2023-12-26 10:14:36 -05:00
|
|
|
FROM node:20-alpine as app
|
2022-06-23 06:17:02 -05:00
|
|
|
WORKDIR /etc/logto
|
|
|
|
COPY --from=builder /etc/logto .
|
|
|
|
EXPOSE 3001
|
2023-05-24 22:26:53 -05:00
|
|
|
ENTRYPOINT ["npm", "run"]
|
|
|
|
CMD ["start"]
|