This repository was archived by the owner on Jun 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
215 lines (174 loc) · 5.72 KB
/
Dockerfile
File metadata and controls
215 lines (174 loc) · 5.72 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# Default build arguments (modify .env instead when "docker compose build")
ARG BUILD_PKP_TOOL=ojs
ARG BUILD_PKP_VERSION=3_3_0-21
ARG BUILD_PKP_APP_OS=alpine:3.22
ARG BUILD_PKP_APP_PATH=/app
ARG BUILD_WEB_SERVER=php:8.3-apache
ARG BUILD_LABEL=notset
# Stage 1: Download PKP source code from released tarball.
FROM ${BUILD_PKP_APP_OS} AS pkp_code
ARG BUILD_PKP_TOOL \
BUILD_PKP_VERSION \
BUILD_PKP_APP_OS \
BUILD_PKP_APP_PATH
RUN apk add --no-cache curl tar && \
mkdir -p "${BUILD_PKP_APP_PATH}" && \
cd "${BUILD_PKP_APP_PATH}" && \
pkpVersion="${BUILD_PKP_VERSION//_/.}" && \
curl -sSL -O "https://pkp.sfu.ca/${BUILD_PKP_TOOL}/download/${BUILD_PKP_TOOL}-${pkpVersion}.tar.gz" && \
tar --strip-components=1 -xzf "${BUILD_PKP_TOOL}-${pkpVersion}.tar.gz" && \
rm ${BUILD_PKP_TOOL}-${pkpVersion}.tar.gz
# Stage 2: Build PHP extensions and dependencies
FROM ${BUILD_WEB_SERVER} AS pkp_build
# Packages needed to build PHP extensions
ENV PKP_DEPS="\
# Basic tools
curl \
unzip \
ca-certificates \
build-essential \
# PHP extension development libraries
libzip-dev \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libonig-dev \
libxml2-dev \
libxslt1-dev \
libfreetype6-dev \
# Modern image formats support
libavif-dev \
# Graphics/X11 support
libxpm-dev \
libfontconfig-dev \
# PostgreSQL development
libpq-dev"
ENV PHP_EXTENSIONS="\
# Image processing
gd \
# Internationalization
gettext \
intl \
# String handling
mbstring \
# Database connectivity - MySQL/MariaDB
mysqli \
pdo_mysql \
# Database connectivity - PostgreSQL
pgsql \
pdo_pgsql \
# XML processing
xml \
xsl \
# Compression
zip \
# PKP 3.5
bcmath \
ftp"
RUN apt-get update && \
apt-get install -y --no-install-recommends $PKP_DEPS && \
\
curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
-o /usr/local/bin/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions $PHP_EXTENSIONS && \
\
apt-get purge -y --auto-remove build-essential && \
rm -rf /var/lib/apt/lists/*
# Stage 3: Final lightweight image
FROM ${BUILD_WEB_SERVER}
ARG BUILD_PKP_TOOL \
BUILD_PKP_VERSION \
BUILD_PKP_APP_PATH \
BUILD_WEB_SERVER \
BUILD_LABEL
LABEL maintainer="Public Knowledge Project <marc.bria@uab.es>"
LABEL org.opencontainers.image.vendor="Public Knowledge Project"
LABEL org.opencontainers.image.title="PKP ${BUILD_PKP_TOOL} Web Application"
LABEL org.opencontainers.image.description="Runs a ${BUILD_PKP_TOOL} application over ${BUILD_WEB_SERVER}."
LABEL build_version="${BUILD_PKP_TOOL}-${BUILD_PKP_VERSION}#${BUILD_LABEL}"
# Environment variables
ENV SERVERNAME="localhost" \
WWW_USER="www-data" \
WWW_PATH_CONF="/etc/apache2/apache2.conf" \
WWW_PATH_ROOT="/var/www" \
HTTPS="on" \
PKP_TOOL="${BUILD_PKP_TOOL}" \
PKP_VERSION="${BUILD_PKP_VERSION}" \
PKP_CLI_INSTALL="0" \
PKP_DB_HOST="${PKP_DB_HOST:-db}" \
PKP_DB_NAME="${PKP_DB_NAME:-pkp}" \
PKP_DB_USER="${PKP_DB_USER:-pkp}" \
PKP_DB_PASSWORD="${PKP_DB_PASSWORD:-changeMePlease}" \
PKP_WEB_CONF="/etc/apache2/conf-enabled/pkp.conf" \
PKP_CONF="config.inc.php" \
PKP_CMD="/usr/local/bin/pkp-start"
ENV PKP_RUNTIME_LIBS="\
# Core libraries
libxml2 \
libxslt1.1 \
libicu72 \
libzip4 \
# Image processing
libjpeg62-turbo \
libpng16-16 \
libfreetype6 \
libonig5 \
libavif15 \
libwebp7 \
# Graphics/X11 support
libxpm4 \
libfontconfig1 \
libx11-6 \
# PostgreSQL runtime
libpq5"
ENV PKP_APPS="\
# If we like cron in the container (under discussion at #179)
cron \
# PDF support: pdf2text
poppler-utils \
# PostScript support: ps2acii
ghostscript \
# Word suport: antiword
antiword "
# Install required apps and runtime libraries
RUN apt-get update && \
apt-get install -y $PKP_APPS $PKP_RUNTIME_LIBS && \
rm -rf /var/lib/apt/lists/*
# Copy PHP extensions and configs from build stage
COPY --from=pkp_build /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=pkp_build /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
COPY --from=pkp_build /usr/local/bin/install-php-extensions /usr/local/bin/install-php-extensions
# Set working directory
WORKDIR ${WWW_PATH_ROOT}/html
# Copy source code and configuration files
COPY --from=pkp_code "${BUILD_PKP_APP_PATH}" .
COPY "templates/pkp/root/" /
COPY "volumes/config/apache.pkp.conf" "${PKP_WEB_CONF}"
# Final configuration steps
RUN a2enmod rewrite ssl && \
mkdir -p /etc/ssl/apache2 "${WWW_PATH_ROOT}/files" /run/apache2 && \
\
echo "log_errors = On" >> /usr/local/etc/php/conf.d/log-errors.ini && \
echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/log-errors.ini && \
\
cp -a config.TEMPLATE.inc.php "${PKP_CONF}" && \
chown -R ${WWW_USER}:${WWW_USER} "${WWW_PATH_ROOT}" && \
\
echo "0 * * * * pkp-run-scheduled" | crontab - && \
\
sed -i -e '\#<Directory />#,\#</Directory>#d' ${WWW_PATH_CONF} && \
sed -i -e "s/^ServerSignature.*/ServerSignature Off/" ${WWW_PATH_CONF} && \
\
. /etc/os-release && \
echo "${PKP_TOOL}-${PKP_VERSION} with ${BUILD_WEB_SERVER} over ${ID}-${VERSION_ID} [build: $(date +%Y%m%d-%H%M%S)]" \
> "${WWW_PATH_ROOT}/container.version" && \
cat "${WWW_PATH_ROOT}/container.version" && \
\
chmod +x "${PKP_CMD}"
# Expose web ports and declare volumes
EXPOSE 80
EXPOSE 443
VOLUME [ "${WWW_PATH_ROOT}/files", "${WWW_PATH_ROOT}/public" ]
# Default start command
CMD "${PKP_CMD}"