build(benchmark): Fix docker image build (#10854)

This commit is contained in:
Tomi Turtiainen 2024-09-17 17:37:07 +03:00 committed by GitHub
parent 0b5299a248
commit 3c15890a5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 3 deletions

View file

@ -9,7 +9,7 @@
"type=bind,source=${localEnv:HOME}/.n8n,target=/home/node/.n8n,consistency=cached" "type=bind,source=${localEnv:HOME}/.n8n,target=/home/node/.n8n,consistency=cached"
], ],
"forwardPorts": [8080, 5678], "forwardPorts": [8080, 5678],
"postCreateCommand": "corepack prepare --activate && pnpm install ", "postCreateCommand": "corepack prepare --activate && pnpm install",
"postAttachCommand": "pnpm build", "postAttachCommand": "pnpm build",
"customizations": { "customizations": {
"codespaces": { "codespaces": {

View file

@ -6,7 +6,7 @@ FROM --platform=linux/amd64 n8nio/base:${NODE_VERSION} AS builder
# Build the application from source # Build the application from source
WORKDIR /src WORKDIR /src
COPY . /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 pnpm install --frozen-lockfile 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 RUN pnpm build
# Delete all dev dependencies # Delete all dev dependencies

View file

@ -8,7 +8,7 @@
}, },
"packageManager": "pnpm@9.6.0", "packageManager": "pnpm@9.6.0",
"scripts": { "scripts": {
"prepare": "lefthook install", "prepare": "node scripts/prepare.mjs",
"preinstall": "node scripts/block-npm-install.js", "preinstall": "node scripts/block-npm-install.js",
"build": "turbo run build", "build": "turbo run build",
"build:backend": "turbo run build:backend", "build:backend": "turbo run build:backend",

View file

@ -33,6 +33,7 @@ COPY --chown=node:node ./packages/@n8n/benchmark/package.json /app/packages/@n8n
COPY --chown=node:node ./patches /app/patches COPY --chown=node:node ./patches /app/patches
COPY --chown=node:node ./scripts /app/scripts COPY --chown=node:node ./scripts /app/scripts
ENV DOCKER_BUILD=true
RUN pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile
# TS config files # TS config files

10
scripts/prepare.mjs Normal file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env node
import { execSync } from 'node:child_process';
// Skip lefthook install in CI or Docker build
if (process.env.CI || process.env.DOCKER_BUILD) {
process.exit(0);
}
execSync('./node_modules/.bin/lefthook install', { stdio: 'inherit' });