-
Notifications
You must be signed in to change notification settings - Fork 236
/
Dockerfile
125 lines (95 loc) · 2.75 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
################### Asset Builder
FROM node:22 AS build-assets
SHELL [ "/bin/bash", "-euo", "pipefail", "-c" ]
ENV NO_UPDATE_NOTIFIER=1
WORKDIR /build/
COPY package.json package-lock.json ./
RUN \
--mount=type=cache,target=/root/.npm,sharing=private \
<<EOT
npm install --verbose
EOT
# not supported yet
#COPY --parents build-assets.mjs root/static ./
COPY build-assets.mjs ./
COPY root/static root/static
RUN <<EOT
npm run build:min
EOT
HEALTHCHECK CMD [ "test", "-e", "root/assets/assets.json" ]
################### Web Server
# hadolint ignore=DL3007
FROM metacpan/metacpan-base:latest 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 cpanfile cpanfile.snapshot ./
RUN \
--mount=type=cache,target=/root/.perl-cpm,sharing=private \
<<EOT
cpm install --show-build-log-on-failure --resolver=snapshot
EOT
ENV PERL5LIB="/app/local/lib/perl5"
ENV PATH="/app/local/bin:${PATH}"
COPY *.md app.psgi *.conf ./
COPY bin bin
COPY lib lib
COPY root root
COPY --from=build-assets /build/root/assets root/assets
CMD [ \
"/uwsgi.sh", \
"--http-socket", ":80" \
]
EXPOSE 80
HEALTHCHECK --start-period=3s CMD [ "curl", "--fail", "http://localhost/healthcheck" ]
################### Development Server
FROM server AS develop
ENV COLUMNS="${COLUMNS:-120}"
ENV PLACK_ENV=development
USER root
RUN \
--mount=type=cache,target=/root/.perl-cpm \
<<EOT
cpm install --show-build-log-on-failure --resolver=snapshot --with-develop
chown -R metacpan:users ./
EOT
USER metacpan
################### Test Runner
FROM develop AS test
ENV NO_UPDATE_NOTIFIER=1
ENV PLACK_ENV=
USER root
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=private \
--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 -
apt-get update
apt-get satisfy -y -f --no-install-recommends 'nodejs (>= 21.6.1)'
npm install -g npm@^10.4.0
EOT
COPY package.json package-lock.json ./
RUN \
--mount=type=cache,target=/root/.npm,sharing=private \
<<EOT
npm install --verbose --include=dev
EOT
RUN \
--mount=type=cache,target=/root/.perl-cpm \
<<EOT
cpm install --show-build-log-on-failure --resolver=snapshot --with-test
EOT
COPY .perlcriticrc .perltidyrc perlimports.toml precious.toml eslint.config.mjs .editorconfig ./
COPY t t
USER metacpan
CMD [ "prove", "-l", "-r", "-j", "2", "t" ]
################### Production Server
FROM server AS production
USER metacpan