-
Notifications
You must be signed in to change notification settings - Fork 327
/
Dockerfile
149 lines (123 loc) · 4.66 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
ARG VERSION=latest
ARG SMARTY_VERSION=4.4.1
ARG SMARTY_URL=https://github.com/smarty-php/smarty/archive/refs/tags/v${SMARTY_VERSION}.tar.gz
ARG COMPOSER_VERSION=lts
ARG COMPOSER_IMAGE=composer/composer:${COMPOSER_VERSION}-bin
ARG BASE_IMAGE=php:8.3-apache
FROM ${COMPOSER_IMAGE} AS composer
FROM ${BASE_IMAGE} AS base
ARG MIRROR=
ARG DEBIAN_MIRROR=${MIRROR:+${MIRROR}/debian}
RUN [ -z "${DEBIAN_MIRROR}" ] || \
sed -e "s#https\?://\(:\?\(:\?deb\)\|\(:\?security\)\)\.debian\.org/debian#${DEBIAN_MIRROR}#g" \
-i \
$([ -e "/etc/apt/sources.list.d/debian.sources" ] && \
echo -n /etc/apt/sources.list.d/debian.sources || \
echo -n /etc/apt/sources.list)
ARG RUNTIME_DEPS=" \
locales \
locales-all \
"
RUN --mount=type=cache,target=/var/lib/apt/lists \
set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends ${RUNTIME_DEPS}; \
:;
ARG LC_CTYPE=en_US.UTF-8
ENV LC_CTYPE=${LC_CTYPE}
ARG ADD_LOCALE_GEN="en_US.UTF-8 UTF-8"
RUN [ -z "$ADD_LOCALE_GEN" ] || \
grep -x "$ADD_LOCALE_GEN" /etc/locale.gen || \
{ echo "$ADD_LOCALE_GEN" >> /etc/locale.gen && /usr/sbin/locale-gen; }
ARG BUILD_DEPS=" \
libbz2-dev \
libicu-dev \
libfreetype6-dev \
libpng-dev \
libjpeg62-turbo-dev \
libwebp-dev \
libldap2-dev \
"
RUN --mount=type=cache,target=/var/lib/apt/lists \
set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends ${BUILD_DEPS}; \
\
docker-php-source extract; \
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
bz2 \
intl \
opcache \
ldap \
gd \
; \
docker-php-source delete; \
a2enmod rewrite; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
apt-get purge -y linux-libc-dev gcc-12 cpp-12; \
ln -s "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
:;
FROM base AS build
WORKDIR /build
ARG SMARTY_VERSION
ARG SMARTY_URL
ARG COMPOSER_IMAGE
COPY --from=composer /composer /usr/bin/composer
ADD $SMARTY_URL ./
RUN set -ex; \
\
SMARTY_DIR=/usr/share/php/smarty${SMARTY_VERSION%%.*}; \
install --owner www-data --group www-data --directory -D "/rootfs${SMARTY_DIR}"; \
tar xzf *.tar.gz -C "/rootfs${SMARTY_DIR}" --strip-components=2 --verbose --owner www-data --group www-data;
RUN set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends git unzip;
ARG INSTALL_PATHS=
ARG EXCLUDE_PATHS=
WORKDIR /build/ssp
RUN --mount=type=cache,target=/root/.composer \
--mount=type=bind,target=/build/ssp,rw \
packaging/docker/install; \
find /etc/apache2/sites-available/ -type f -name \*.conf -exec install -p -m 644 -D {} /rootfs{} \; ; \
sed -e "s#/var/www/html#/var/www/htdocs#g" -i /rootfs/etc/apache2/sites-available/*; \
:;
FROM base
ARG VERSION
ARG BASE_IMAGE
LABEL org.opencontainers.image.authors='LTB-project.org, [email protected]' \
org.opencontainers.image.base.name="${BASE_IMAGE}" \
org.opencontainers.image.description='Self Service Password is a simple PHP application that allows users to change their password on an LDAP directory' \
org.opencontainers.image.url='https://ltb-project.org/documentation/self-service-password.html' \
org.opencontainers.image.ref.name='self-service-password' \
org.opencontainers.image.documentation='https://self-service-password.readthedocs.io/' \
org.opencontainers.image.title='self-service-password docker image' \
org.opencontainers.image.source='https://github.com/ltb-project/self-service-password/' \
org.opencontainers.image.vendor='LTB-project.org' \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.licenses='GPL-2+'
COPY --from=build /rootfs /
WORKDIR /var/www/htdocs
VOLUME [ "/var/www/templates_c", "/var/www/conf", "/var/www/cache" ]
EXPOSE 80
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "apache2-foreground" ]