diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c84846ad24..fe0dde28aa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,12 +1,14 @@ ---- version: 2 updates: - - package-ecosystem: 'github-actions' - directory: '/' + - package-ecosystem: github-actions + directory: / schedule: - # Check for updates to GitHub Actions every week - interval: 'weekly' + interval: weekly - package-ecosystem: npm - directory: '/' + directory: / schedule: - interval: 'weekly' + interval: weekly + - package-ecosystem: docker + directory: / + schedule: + interval: daily diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 6ae1b665fa..a9b56fc7ec 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -1,4 +1,4 @@ -name: Enable Auto-Merge For metacpan-automation +name: Enable Auto-Merge For bots on: pull_request_target: types: [opened] diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 3832540521..e23dfd1ce2 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -53,7 +53,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ${{ github.repository }} + docker.io/${{ github.repository }} ghcr.io/${{ github.repository }} flavor: | latest=false @@ -72,7 +72,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} - name: Update deployed image - if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }} + if: contains( format(',{0},', join( fromJSON(steps.meta.outputs.json).tags, ',' ) ), ':latest,' ) uses: benc-uk/workflow-dispatch@v1 with: repo: metacpan/metacpan-k8s diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4b17f4282..256766273c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: load: true - name: Run Perl tests run: > - docker run -d -i -p 5001:80 + docker run -d -i -p 5001:8000 ${{ steps.docker-build-test.outputs.imageid }} - uses: actions/setup-node@v4 with: diff --git a/Dockerfile b/Dockerfile index fe0a303322..2ca4df520c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ +ARG SLIM_BUILD +ARG MAYBE_BASE_BUILD=${SLIM_BUILD:+server-base-slim} +ARG BASE_BUILD=${MAYBE_BASE_BUILD:-server-base} + ################### Asset Builder -FROM node:22 AS build-assets -SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ] +FROM node:24-alpine AS build-assets ENV NO_UPDATE_NOTIFIER=1 +SHELL [ "/bin/sh", "-euo", "pipefail", "-c" ] WORKDIR /build/ @@ -24,9 +28,12 @@ EOT HEALTHCHECK CMD [ "test", "-e", "root/assets/assets.json" ] -################### Web Server -# hadolint ignore=DL3007 -FROM metacpan/metacpan-base:latest AS server +################### Web Server Base +FROM metacpan/metacpan-base:main-20250531-090128 AS server-base +FROM metacpan/metacpan-base:main-20250531-090129-slim AS server-base-slim + +################### CPAN Prereqs +FROM server-base AS build-cpan-prereqs SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ] RUN \ @@ -46,32 +53,54 @@ RUN \ cpm install --show-build-log-on-failure --resolver=snapshot EOT -ENV PERL5LIB="/app/local/lib/perl5" -ENV PATH="/app/local/bin:${PATH}" +################### Web Server +# false positive +# hadolint ignore=DL3006 +FROM ${BASE_BUILD} AS server +SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ] + +RUN \ + --mount=type=cache,target=/var/cache/apt,sharing=private \ + --mount=type=cache,target=/var/lib/apt/lists,sharing=private \ +<= 0.30.2)' +EOT + +WORKDIR /app/ COPY *.md app.psgi log4perl* metacpan_web.* metacpan_web_local.* ./ COPY bin bin COPY lib lib COPY root root + COPY --from=build-assets /build/root/assets root/assets +COPY --from=build-cpan-prereqs /app/local local + +ENV PERL5LIB="/app/local/lib/perl5" +ENV PATH="/app/local/bin:${PATH}" +ENV METACPAN_WEB_HOME=/app CMD [ \ "/uwsgi.sh", \ - "--http-socket", ":80" \ + "--http-socket", ":8000" \ ] -EXPOSE 80 +EXPOSE 8000 -HEALTHCHECK --start-period=3s CMD [ "curl", "--fail", "http://localhost/healthcheck" ] +HEALTHCHECK --start-period=3s CMD [ "curl", "--fail", "http://localhost:8000/healthcheck" ] ################### Development Server FROM server AS develop +SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ] ENV COLUMNS=120 ENV PLACK_ENV=development USER root +COPY cpanfile cpanfile.snapshot ./ + RUN \ --mount=type=cache,target=/root/.perl-cpm \ <= 21.6.1)' - npm install -g npm@^10.4.0 + apt-get satisfy -y -f --no-install-recommends 'nodejs (>= 24.1.0)' + npm install -g npm@^11.4.1 EOT COPY package.json package-lock.json ./ diff --git a/docker-compose.yml b/docker-compose.yml index 8f7bfd50e8..07b1cffea8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,12 @@ services: - './root/static/:/build/root/static/' - 'web-assets:/build/root/assets/' command: ['./build-assets.mjs', '--watch'] + develop: + watch: + - path: ./build-assets.mjs + action: rebuild + - path: ./package.json + action: rebuild web-server: build: context: . @@ -16,7 +22,7 @@ services: - 'web-assets:/app/root/assets/' - '/app/local' ports: - - '5001:80' + - '5001:8000' environment: # default is 120, shorten to work with compose label COLUMNS: 96 diff --git a/lib/MetaCPAN/Web.pm b/lib/MetaCPAN/Web.pm index 1e58e93ae7..c5d76aa7d6 100644 --- a/lib/MetaCPAN/Web.pm +++ b/lib/MetaCPAN/Web.pm @@ -43,14 +43,7 @@ __PACKAGE__->config( __PACKAGE__->log( Log::Log4perl::Catalyst->new( undef, autoflush => 1 ) ); -# Squash warnings when not in a terminal (like when running under Docker) -# Catalyst throws warnings if it can't detect the size, even if $ENV{COLUMNS} -# exists. Just lie to it to shut it up. -use Term::Size::Perl (); -if ( !Term::Size::Perl::chars() ) { - no warnings 'once', 'redefine'; - *Term::Size::Perl::chars = sub { $ENV{COLUMNS} || 80 }; -} +$ENV{COLUMNS} ||= 80; after prepare_action => sub { my ($self) = @_; diff --git a/metacpan_web.yaml b/metacpan_web.yaml index 534b1a2716..55250b9ea1 100644 --- a/metacpan_web.yaml +++ b/metacpan_web.yaml @@ -1,5 +1,3 @@ -name: MetaCPAN::Web - api: https://api.metacpan.org/v1 source_host: https://st.aticpan.org web_host: https://metacpan.org