11# Initialize builder layer
22FROM node:lts-alpine AS builder
33ENV NODE_ENV production
4+ ENV PNPM_HOME="/pnpm"
5+ ENV PATH="$PNPM_HOME/bin:$PATH"
6+ WORKDIR /app
47# Install necessary tools
58RUN 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
1016COPY . .
1117RUN 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
1622FROM node:lts-alpine AS runner
1723ENV NODE_ENV production
24+ ENV PNPM_HOME="/pnpm"
25+ ENV PATH="$PNPM_HOME/bin:$PATH"
26+ WORKDIR /app
1827# Install necessary tools
1928RUN 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
2537COPY --from=builder /app/.next ./.next
@@ -28,7 +40,6 @@ COPY --from=builder /app/.next ./.next
2840COPY --from=builder /app/node_modules ./node_modules
2941COPY --from=builder /app/migrations ./migrations
3042COPY --from=builder /app/public ./public
31- COPY --from=builder /app/package.json ./
3243COPY --from=builder /app/.env.production ./
3344COPY --from=builder /app/next.config.ts ./
3445
0 commit comments