mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
d2eb7998bd
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run
45 lines
1.5 KiB
Docker
45 lines
1.5 KiB
Docker
ARG NODE_VERSION=20
|
|
|
|
# 1. Create an image to build n8n
|
|
FROM --platform=linux/amd64 n8nio/base:${NODE_VERSION} AS builder
|
|
|
|
# Build the application from source
|
|
WORKDIR /src
|
|
COPY . /src
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store --mount=type=cache,id=pnpm-metadata,target=/root/.cache/pnpm/metadata DOCKER_BUILD=true pnpm install --frozen-lockfile
|
|
RUN pnpm build
|
|
|
|
# Delete all dev dependencies
|
|
RUN jq 'del(.pnpm.patchedDependencies)' package.json > package.json.tmp; mv package.json.tmp package.json
|
|
RUN node .github/scripts/trim-fe-packageJson.js
|
|
|
|
# Delete any source code, source-mapping, or typings
|
|
RUN find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" -o -name "*.tsbuildinfo" | xargs rm -rf
|
|
|
|
# Deploy the `n8n` package into /compiled
|
|
RUN mkdir /compiled
|
|
RUN NODE_ENV=production DOCKER_BUILD=true pnpm --filter=n8n --prod --no-optional deploy /compiled
|
|
|
|
# 2. Start with a new clean image with just the code that is needed to run n8n
|
|
FROM n8nio/base:${NODE_VERSION}
|
|
ENV NODE_ENV=production
|
|
|
|
ARG N8N_RELEASE_TYPE=dev
|
|
ENV N8N_RELEASE_TYPE=${N8N_RELEASE_TYPE}
|
|
|
|
WORKDIR /home/node
|
|
COPY --from=builder /compiled /usr/local/lib/node_modules/n8n
|
|
COPY docker/images/n8n/docker-entrypoint.sh /
|
|
|
|
RUN \
|
|
cd /usr/local/lib/node_modules/n8n && \
|
|
npm rebuild sqlite3 && \
|
|
cd - && \
|
|
ln -s /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \
|
|
mkdir .n8n && \
|
|
chown node:node .n8n
|
|
|
|
ENV SHELL /bin/sh
|
|
USER node
|
|
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
|