Unverified Commit ed396cad authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

CI: Use pnpm lockfile for next-stats-action (#92488)

Previously, we were just copying the `package.json` into the container and `pnpm install`ing it.

This wouldn't respect the lockfile or `minimumReleaseAge`. This uses `pnpm deploy` based on the documentation here: https://pnpm.io/docker
parent 77446473
# syntax=docker.io/docker/dockerfile:1 # syntax=docker.io/docker/dockerfile:1
FROM ubuntu:24.04 FROM ubuntu:24.04 AS base
LABEL com.github.actions.name="Next.js PR Stats"
LABEL com.github.actions.description="Compares stats of a PR with the main branch"
LABEL repository="https://github.com/vercel/next-stats-action"
ENV DEBIAN_FRONTEND=noninteractive
# use apt-get instead of apt, because apt does not have a stable CLI interface # use apt-get instead of apt, because apt does not have a stable CLI interface
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y --no-install-recommends curl ca-certificates git RUN apt-get install -y --no-install-recommends curl ca-certificates git
...@@ -16,17 +11,30 @@ RUN curl -sfLS https://install-node.vercel.app/v20.9.0 | bash -s -- -f ...@@ -16,17 +11,30 @@ RUN curl -sfLS https://install-node.vercel.app/v20.9.0 | bash -s -- -f
RUN npm i -g corepack@0.34.6 RUN npm i -g corepack@0.34.6
RUN corepack enable RUN corepack enable
WORKDIR /next-stats
# Install node_modules
COPY package.json ./
RUN pnpm install --production
# Do this copy after the pnpm install to optimize docker caching FROM base AS pnpm-deploy
COPY --exclude=node_modules . .
WORKDIR /dot-github
COPY --exclude=node_modules --exclude=actions/*/node_modules . .
RUN ls -l
RUN pnpm deploy --filter=next-stats-action --production /next-stats
FROM base AS next-stats-action
LABEL com.github.actions.name="Next.js PR Stats"
LABEL com.github.actions.description="Compares stats of a PR with the main branch"
LABEL repository="https://github.com/vercel/next.js"
RUN git config --global user.email 'stats@localhost' && \ RUN git config --global user.email 'stats@localhost' && \
git config --global user.name 'next stats' git config --global user.name 'next stats'
WORKDIR /next-stats
COPY --from=pnpm-deploy /next-stats .
RUN pnpm install --production
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
...@@ -7,4 +7,6 @@ inputs: ...@@ -7,4 +7,6 @@ inputs:
required: false required: false
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile' # this dockerfile must be located in the parent directory, otherwise
# `pnpm deploy` can't read the pnpm-lock.yaml
image: '../../next-stats-action.Dockerfile'
{ {
"name": "next-stats-action",
"private": true, "private": true,
"main": "src/index.js", "main": "src/index.js",
"dependencies": { "dependencies": {
......
# syntax=docker.io/docker/dockerfile:1
FROM ubuntu:24.04 AS base
# use apt-get instead of apt, because apt does not have a stable CLI interface
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y --no-install-recommends curl ca-certificates git
RUN curl -sfLS https://install-node.vercel.app/v20.9.0 | bash -s -- -f
RUN npm i -g corepack@0.34.6
RUN corepack enable
FROM base AS pnpm-deploy
WORKDIR /dot-github
COPY pnpm-lock.yaml pnpm-workspace.yaml .
COPY --exclude=actions/*/node_modules \
actions/next-stats-action actions/next-stats-action
RUN pnpm deploy --filter=next-stats-action --production /next-stats
FROM base AS next-stats-action
LABEL com.github.actions.name="Next.js PR Stats"
LABEL com.github.actions.description="Compares stats of a PR with the main branch"
LABEL repository="https://github.com/vercel/next.js"
RUN git config --global user.email 'stats@localhost' && \
git config --global user.name 'next stats'
WORKDIR /next-stats
COPY --from=pnpm-deploy /next-stats .
COPY actions/next-stats-action/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
packages: packages:
- 'actions/*' - 'actions/*'
injectWorkspacePackages: true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment