Skip to content

Docker and GitHub Action updates #3373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Enable Auto-Merge For metacpan-automation
name: Enable Auto-Merge For bots
on:
pull_request_target:
types: [opened]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
56 changes: 43 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/

Expand All @@ -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 \
Expand All @@ -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 \
<<EOT
apt-get update
apt-get satisfy -y -f --no-install-recommends 'libcmark-dev (>= 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 \
<<EOT
Expand All @@ -83,6 +112,7 @@ USER metacpan

################### Test Runner
FROM develop AS test
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]

ENV NO_UPDATE_NOTIFIER=1
ENV PLACK_ENV=
Expand All @@ -94,10 +124,10 @@ RUN \
--mount=type=cache,target=/var/lib/apt/lists,sharing=private \
--mount=type=cache,target=/root/.npm,sharing=private \
<<EOT
curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt-get update
apt-get satisfy -y -f --no-install-recommends 'nodejs (>= 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 ./
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand All @@ -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
Expand Down
9 changes: 1 addition & 8 deletions lib/MetaCPAN/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) = @_;
Expand Down
2 changes: 0 additions & 2 deletions metacpan_web.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: MetaCPAN::Web

api: https://api.metacpan.org/v1
source_host: https://st.aticpan.org
web_host: https://metacpan.org
Expand Down
Loading