Skip to content

Commit 9b9dbed

Browse files
committed
fix: deploy
1 parent b99e9da commit 9b9dbed

4 files changed

Lines changed: 27 additions & 10 deletions

File tree

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ FROM node:20-alpine AS builder
44
# Set working directory
55
WORKDIR /app
66

7-
# Copy package files
7+
# Copy package files and postinstall script
88
COPY package*.json ./
9+
COPY scripts ./scripts
910

1011
# Install ALL dependencies (including dev dependencies for build)
1112
RUN npm ci && npm cache clean --force
@@ -35,8 +36,9 @@ RUN addgroup -g 1001 -S nodejs && \
3536
# Set working directory
3637
WORKDIR /app
3738

38-
# Copy package files
39+
# Copy package files and postinstall script (required before npm ci)
3940
COPY package*.json ./
41+
COPY scripts ./scripts
4042

4143
# Install only production dependencies
4244
RUN npm ci --omit=dev && npm cache clean --force

Dockerfile.canary

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ FROM node:20-alpine AS builder
44
# Set working directory
55
WORKDIR /app
66

7-
# Copy package files
7+
# Copy package files and postinstall script (required before npm ci)
88
COPY package*.json ./
9+
COPY scripts ./scripts
910

1011
# Install ALL dependencies (including dev dependencies for build)
1112
RUN npm ci && npm cache clean --force
@@ -35,8 +36,9 @@ RUN addgroup -g 1001 -S nodejs && \
3536
# Set working directory
3637
WORKDIR /app
3738

38-
# Copy package files
39+
# Copy package files and postinstall script (required before npm ci)
3940
COPY package*.json ./
41+
COPY scripts ./scripts
4042

4143
# Install only production dependencies
4244
RUN npm ci --omit=dev && npm cache clean --force

Dockerfile.dev

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ RUN apk add --no-cache dumb-init
55

66
WORKDIR /app
77

8-
# Copy package files
8+
# Copy package files and postinstall script
99
COPY package*.json ./
10+
COPY scripts ./scripts
1011

1112
# Install all dependencies (including dev dependencies)
1213
RUN npm install

scripts/verify-node-modules.mjs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ if (!existsSync(nm)) {
1111
}
1212

1313
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
14-
const deps = {
15-
...pkg.dependencies,
16-
...pkg.devDependencies,
17-
...(pkg.optionalDependencies ?? {}),
18-
}
14+
15+
const omit = (process.env.npm_config_omit ?? '')
16+
.split(/[,+]/)
17+
.map((s) => s.trim())
18+
.filter(Boolean)
19+
const omitDev = omit.includes('dev')
20+
21+
const deps = omitDev
22+
? {
23+
...pkg.dependencies,
24+
...(pkg.optionalDependencies ?? {}),
25+
}
26+
: {
27+
...pkg.dependencies,
28+
...pkg.devDependencies,
29+
...(pkg.optionalDependencies ?? {}),
30+
}
1931

2032
for (const name of Object.keys(deps)) {
2133
const segments = name.split('/')

0 commit comments

Comments
 (0)