2022-11-07 08:23:08 -08:00
|
|
|
ARG NODE_VERSION=16
|
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
|
|
|
|
2022-11-09 08:32:05 -08:00
|
|
|
COPY turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
|
2022-11-21 08:54:44 -08:00
|
|
|
COPY scripts ./scripts
|
2022-08-31 06:25:52 -07:00
|
|
|
COPY packages ./packages
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-11-09 08:32:05 -08:00
|
|
|
RUN corepack enable && corepack prepare --activate
|
2022-08-31 06:25:52 -07:00
|
|
|
RUN chown -R node:node .
|
|
|
|
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
|
|
|
|
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
|
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}
|
|
|
|
COPY --from=builder /home/node ./
|
|
|
|
COPY docker/images/n8n-custom/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
|
|
|
|
ENTRYPOINT ["tini", "--", "./docker-entrypoint.sh"]
|