2023-06-02 06:23:28 -07:00
|
|
|
ARG NODE_VERSION=18
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-08-31 06:25:52 -07:00
|
|
|
# 1. Create an image to build n8n
|
|
|
|
FROM n8nio/base:${NODE_VERSION} as builder
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2023-08-01 08:32:43 -07:00
|
|
|
COPY --chown=node:node turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml jest.config.js tsconfig*.json ./
|
2023-04-12 06:45:01 -07:00
|
|
|
COPY --chown=node:node scripts ./scripts
|
|
|
|
COPY --chown=node:node packages ./packages
|
|
|
|
COPY --chown=node:node patches ./patches
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2023-06-07 04:28:06 -07:00
|
|
|
RUN apk add --update jq
|
2022-11-09 08:32:05 -08:00
|
|
|
RUN corepack enable && corepack prepare --activate
|
2022-08-31 06:25:52 -07:00
|
|
|
USER node
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-11-09 08:32:05 -08:00
|
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
RUN pnpm build
|
|
|
|
RUN rm -rf node_modules
|
2023-01-30 02:02:05 -08:00
|
|
|
RUN jq 'del(.pnpm.patchedDependencies)' package.json > package.json.tmp; mv package.json.tmp package.json
|
2023-08-31 05:05:12 -07:00
|
|
|
RUN node scripts/trim-fe-packageJson.js
|
2022-11-09 08:32:05 -08:00
|
|
|
RUN NODE_ENV=production pnpm install --prod --no-optional
|
2022-11-30 18:12:34 -08:00
|
|
|
RUN find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" -o -name "*.tsbuildinfo" | xargs rm -rf
|
2023-01-09 07:42:53 -08:00
|
|
|
RUN rm -rf packages/@n8n_io/eslint-config packages/editor-ui/src packages/editor-ui/node_modules packages/design-system
|
2022-11-09 08:32:05 -08:00
|
|
|
RUN rm -rf patches .npmrc *.yaml node_modules/.cache packages/**/node_modules/.cache packages/**/.turbo .config .cache .local .node /tmp/*
|
2020-05-15 00:31:55 -07:00
|
|
|
|
|
|
|
|
2022-08-31 06:25:52 -07:00
|
|
|
# 2. Start with a new clean image with just the code that is needed to run n8n
|
|
|
|
FROM n8nio/base:${NODE_VERSION}
|
2023-10-03 12:24:53 -07:00
|
|
|
ARG N8N_RELEASE_TYPE=dev
|
2022-12-21 08:12:12 -08:00
|
|
|
COPY --from=builder /home/node /usr/local/lib/node_modules/n8n
|
|
|
|
RUN ln -s /usr/local/lib/node_modules/n8n/packages/cli/bin/n8n /usr/local/bin/n8n
|
2023-06-07 04:28:06 -07:00
|
|
|
|
|
|
|
COPY docker/images/n8n/docker-entrypoint.sh /
|
2022-08-31 10:34:30 -07:00
|
|
|
|
|
|
|
RUN \
|
|
|
|
mkdir .n8n && \
|
|
|
|
chown node:node .n8n
|
2022-08-31 06:25:52 -07:00
|
|
|
USER node
|
|
|
|
ENV NODE_ENV=production
|
2023-10-03 11:49:04 -07:00
|
|
|
ENV N8N_RELEASE_TYPE=${N8N_RELEASE_TYPE}
|
2022-12-07 06:54:26 -08:00
|
|
|
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
|