Skip to content

Commit 425ec97

Browse files
committed
Remove Corepack and migrate pnpm version pin to avoid pnpm failures
1 parent c93b88f commit 425ec97

4 files changed

Lines changed: 37 additions & 14 deletions

File tree

‎.github/workflows/ci-cd.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ jobs:
6868
API_KEY: ${{ secrets.API_KEY }}
6969
- name: Run Stylelint
7070
run: pnpm stylelint '**/*.{css,scss,less,js,tsx}'
71+
docker:
72+
name: Build Docker image
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v7
76+
- run: docker build --tag security-vulnerability-examples-next-js-postgres .
7177
cd:
7278
name: Deploy to Fly.io
7379
runs-on: ubuntu-latest

‎Dockerfile‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# Initialize builder layer
22
FROM node:lts-alpine AS builder
33
ENV NODE_ENV production
4+
ENV PNPM_HOME="/pnpm"
5+
ENV PATH="$PNPM_HOME/bin:$PATH"
6+
WORKDIR /app
47
# Install necessary tools
58
RUN apk add --no-cache libc6-compat yq build-base g++ cairo-dev jpeg-dev pango-dev giflib-dev --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
69
# Install pnpm
7-
RUN corepack enable && corepack prepare pnpm@latest --activate
8-
WORKDIR /app
10+
COPY package.json ./
11+
RUN cd / \
12+
&& ENV="$HOME/.shrc" SHELL=/bin/sh npx --yes get-pnpm \
13+
"$(node --input-type=module --eval \
14+
'console.log((await import("/app/package.json", { with: { type: "json" } })).default.devEngines.packageManager.version)')"
915
# Copy the content of the project to the machine
1016
COPY . .
1117
RUN yq --inplace --output-format=json '(.dependencies = .dependencies * (.devDependencies | to_entries | map(select(.key | test("^(typescript|@types/*|eslint-config-upleveled)$"))) | from_entries)) | (.devDependencies = {})' package.json
@@ -15,11 +21,17 @@ RUN pnpm build
1521
# Initialize runner layer
1622
FROM node:lts-alpine AS runner
1723
ENV NODE_ENV production
24+
ENV PNPM_HOME="/pnpm"
25+
ENV PATH="$PNPM_HOME/bin:$PATH"
26+
WORKDIR /app
1827
# Install necessary tools
1928
RUN apk add bash postgresql cairo pango jpeg musl giflib pixman pangomm libjpeg-turbo freetype
2029
# Install pnpm
21-
RUN corepack enable && corepack prepare pnpm@latest --activate
22-
WORKDIR /app
30+
COPY --from=builder /app/package.json ./
31+
RUN cd / \
32+
&& ENV="$HOME/.shrc" SHELL=/bin/sh npx --yes get-pnpm \
33+
"$(node --input-type=module --eval \
34+
'console.log((await import("/app/package.json", { with: { type: "json" } })).default.devEngines.packageManager.version)')"
2335

2436
# Copy built app
2537
COPY --from=builder /app/.next ./.next
@@ -28,7 +40,6 @@ COPY --from=builder /app/.next ./.next
2840
COPY --from=builder /app/node_modules ./node_modules
2941
COPY --from=builder /app/migrations ./migrations
3042
COPY --from=builder /app/public ./public
31-
COPY --from=builder /app/package.json ./
3243
COPY --from=builder /app/.env.production ./
3344
COPY --from=builder /app/next.config.ts ./
3445

‎package.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@
4646
"stylelint-config-upleveled": "2.0.5",
4747
"typescript": "6.0.3"
4848
},
49-
"packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8",
49+
"devEngines": {
50+
"packageManager": {
51+
"name": "pnpm",
52+
"version": "11.26.0",
53+
"onFail": "download"
54+
}
55+
},
5056
"pnpm": {
5157
"overrides": {
5258
"node-addon-api": "8.9.2",

‎pnpm-workspace.yaml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ minimumReleaseAgeExclude:
3333
- dompurify@3.3.2 || 3.4.0 || 3.4.8 || 3.4.9 || 3.4.11 || 3.4.13
3434

3535
# Allow build scripts for trusted dependencies
36-
# - https://pnpm.io/settings#onlybuiltdependencies
37-
onlyBuiltDependencies:
38-
- bcrypt
39-
- canvas
40-
- esbuild
41-
- libpg-query
42-
- sharp
43-
- unrs-resolver
36+
# - https://pnpm.io/settings#allowbuilds
37+
allowBuilds:
38+
bcrypt: true
39+
canvas: true
40+
esbuild: true
41+
libpg-query: true
42+
sharp: true
43+
unrs-resolver: true
4444

4545
# Fail on pnpm ignored build scripts
4646
# - https://pnpm.io/settings#strictdepbuilds

0 commit comments

Comments
 (0)