Skip to content

Commit da9c6dc

Browse files
authored
Merge pull request #3373 from metacpan/haarg/docker-and-actions-updates
Docker and GitHub Action updates
2 parents 8da5b21 + ab6d690 commit da9c6dc

File tree

8 files changed

+64
-35
lines changed

8 files changed

+64
-35
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
---
21
version: 2
32
updates:
4-
- package-ecosystem: 'github-actions'
5-
directory: '/'
3+
- package-ecosystem: github-actions
4+
directory: /
65
schedule:
7-
# Check for updates to GitHub Actions every week
8-
interval: 'weekly'
6+
interval: weekly
97
- package-ecosystem: npm
10-
directory: '/'
8+
directory: /
119
schedule:
12-
interval: 'weekly'
10+
interval: weekly
11+
- package-ecosystem: docker
12+
directory: /
13+
schedule:
14+
interval: daily

.github/workflows/automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Enable Auto-Merge For metacpan-automation
1+
name: Enable Auto-Merge For bots
22
on:
33
pull_request_target:
44
types: [opened]

.github/workflows/build-container.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
uses: docker/metadata-action@v5
5454
with:
5555
images: |
56-
${{ github.repository }}
56+
docker.io/${{ github.repository }}
5757
ghcr.io/${{ github.repository }}
5858
flavor: |
5959
latest=false
@@ -72,7 +72,7 @@ jobs:
7272
labels: ${{ steps.meta.outputs.labels }}
7373
annotations: ${{ steps.meta.outputs.annotations }}
7474
- name: Update deployed image
75-
if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }}
75+
if: contains( format(',{0},', join( fromJSON(steps.meta.outputs.json).tags, ',' ) ), ':latest,' )
7676
uses: benc-uk/workflow-dispatch@v1
7777
with:
7878
repo: metacpan/metacpan-k8s

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
load: true
7979
- name: Run Perl tests
8080
run: >
81-
docker run -d -i -p 5001:80
81+
docker run -d -i -p 5001:8000
8282
${{ steps.docker-build-test.outputs.imageid }}
8383
- uses: actions/setup-node@v4
8484
with:

Dockerfile

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
ARG SLIM_BUILD
2+
ARG MAYBE_BASE_BUILD=${SLIM_BUILD:+server-base-slim}
3+
ARG BASE_BUILD=${MAYBE_BASE_BUILD:-server-base}
4+
15
################### Asset Builder
26

3-
FROM node:22 AS build-assets
4-
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]
7+
FROM node:24-alpine AS build-assets
58
ENV NO_UPDATE_NOTIFIER=1
9+
SHELL [ "/bin/sh", "-euo", "pipefail", "-c" ]
610

711
WORKDIR /build/
812

@@ -24,9 +28,12 @@ EOT
2428

2529
HEALTHCHECK CMD [ "test", "-e", "root/assets/assets.json" ]
2630

27-
################### Web Server
28-
# hadolint ignore=DL3007
29-
FROM metacpan/metacpan-base:latest AS server
31+
################### Web Server Base
32+
FROM metacpan/metacpan-base:main-20250531-090128 AS server-base
33+
FROM metacpan/metacpan-base:main-20250531-090129-slim AS server-base-slim
34+
35+
################### CPAN Prereqs
36+
FROM server-base AS build-cpan-prereqs
3037
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]
3138

3239
RUN \
@@ -46,32 +53,54 @@ RUN \
4653
cpm install --show-build-log-on-failure --resolver=snapshot
4754
EOT
4855

49-
ENV PERL5LIB="/app/local/lib/perl5"
50-
ENV PATH="/app/local/bin:${PATH}"
56+
################### Web Server
57+
# false positive
58+
# hadolint ignore=DL3006
59+
FROM ${BASE_BUILD} AS server
60+
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]
61+
62+
RUN \
63+
--mount=type=cache,target=/var/cache/apt,sharing=private \
64+
--mount=type=cache,target=/var/lib/apt/lists,sharing=private \
65+
<<EOT
66+
apt-get update
67+
apt-get satisfy -y -f --no-install-recommends 'libcmark-dev (>= 0.30.2)'
68+
EOT
69+
70+
WORKDIR /app/
5171

5272
COPY *.md app.psgi log4perl* metacpan_web.* metacpan_web_local.* ./
5373
COPY bin bin
5474
COPY lib lib
5575
COPY root root
76+
5677
COPY --from=build-assets /build/root/assets root/assets
78+
COPY --from=build-cpan-prereqs /app/local local
79+
80+
ENV PERL5LIB="/app/local/lib/perl5"
81+
ENV PATH="/app/local/bin:${PATH}"
82+
ENV METACPAN_WEB_HOME=/app
5783

5884
CMD [ \
5985
"/uwsgi.sh", \
60-
"--http-socket", ":80" \
86+
"--http-socket", ":8000" \
6187
]
6288

63-
EXPOSE 80
89+
EXPOSE 8000
6490

65-
HEALTHCHECK --start-period=3s CMD [ "curl", "--fail", "http://localhost/healthcheck" ]
91+
HEALTHCHECK --start-period=3s CMD [ "curl", "--fail", "http://localhost:8000/healthcheck" ]
6692

6793
################### Development Server
6894
FROM server AS develop
95+
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]
6996

7097
ENV COLUMNS=120
7198
ENV PLACK_ENV=development
7299

73100
USER root
74101

102+
COPY cpanfile cpanfile.snapshot ./
103+
75104
RUN \
76105
--mount=type=cache,target=/root/.perl-cpm \
77106
<<EOT
@@ -83,6 +112,7 @@ USER metacpan
83112

84113
################### Test Runner
85114
FROM develop AS test
115+
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]
86116

87117
ENV NO_UPDATE_NOTIFIER=1
88118
ENV PLACK_ENV=
@@ -94,10 +124,10 @@ RUN \
94124
--mount=type=cache,target=/var/lib/apt/lists,sharing=private \
95125
--mount=type=cache,target=/root/.npm,sharing=private \
96126
<<EOT
97-
curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
127+
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
98128
apt-get update
99-
apt-get satisfy -y -f --no-install-recommends 'nodejs (>= 21.6.1)'
100-
npm install -g npm@^10.4.0
129+
apt-get satisfy -y -f --no-install-recommends 'nodejs (>= 24.1.0)'
130+
npm install -g npm@^11.4.1
101131
EOT
102132

103133
COPY package.json package-lock.json ./

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ services:
77
- './root/static/:/build/root/static/'
88
- 'web-assets:/build/root/assets/'
99
command: ['./build-assets.mjs', '--watch']
10+
develop:
11+
watch:
12+
- path: ./build-assets.mjs
13+
action: rebuild
14+
- path: ./package.json
15+
action: rebuild
1016
web-server:
1117
build:
1218
context: .
@@ -16,7 +22,7 @@ services:
1622
- 'web-assets:/app/root/assets/'
1723
- '/app/local'
1824
ports:
19-
- '5001:80'
25+
- '5001:8000'
2026
environment:
2127
# default is 120, shorten to work with compose label
2228
COLUMNS: 96

lib/MetaCPAN/Web.pm

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,7 @@ __PACKAGE__->config(
4343

4444
__PACKAGE__->log( Log::Log4perl::Catalyst->new( undef, autoflush => 1 ) );
4545

46-
# Squash warnings when not in a terminal (like when running under Docker)
47-
# Catalyst throws warnings if it can't detect the size, even if $ENV{COLUMNS}
48-
# exists. Just lie to it to shut it up.
49-
use Term::Size::Perl ();
50-
if ( !Term::Size::Perl::chars() ) {
51-
no warnings 'once', 'redefine';
52-
*Term::Size::Perl::chars = sub { $ENV{COLUMNS} || 80 };
53-
}
46+
$ENV{COLUMNS} ||= 80;
5447

5548
after prepare_action => sub {
5649
my ($self) = @_;

metacpan_web.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
name: MetaCPAN::Web
2-
31
api: https://api.metacpan.org/v1
42
source_host: https://st.aticpan.org
53
web_host: https://metacpan.org

0 commit comments

Comments
 (0)