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-10-12 01:08:57 -07:00
|
|
|
RUN npm install -g run-script-os turbo@1.5.5
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-09-09 09:00:18 -07:00
|
|
|
COPY turbo.json package.json package-lock.json tsconfig.json ./
|
2022-08-31 06:25:52 -07:00
|
|
|
COPY packages ./packages
|
2022-09-23 07:14:28 -07:00
|
|
|
COPY patches ./patches
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-08-31 06:25:52 -07:00
|
|
|
RUN chown -R node:node .
|
2022-03-04 05:46:00 -08:00
|
|
|
RUN npm config set legacy-peer-deps true
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-08-31 06:25:52 -07:00
|
|
|
USER node
|
2020-05-15 00:31:55 -07:00
|
|
|
|
2022-08-31 06:25:52 -07:00
|
|
|
RUN \
|
2022-09-19 02:07:28 -07:00
|
|
|
npm install && \
|
2022-08-31 06:25:52 -07:00
|
|
|
npm run build && \
|
|
|
|
# TODO: removing dev dependecies is deleting `bn.js`, which breaks the Snowflake node
|
|
|
|
npm prune --omit=dev && \
|
|
|
|
npm i --omit=dev bn.js && \
|
2022-09-09 09:00:18 -07:00
|
|
|
find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" | xargs rm &&\
|
2022-08-31 06:25:52 -07:00
|
|
|
rm -rf node_modules/.cache packages/*/node_modules/.cache packages/*/.turbo .config .npm /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"]
|