-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathDockerfile-debian.templ
122 lines (112 loc) · 4.97 KB
/
Dockerfile-debian.templ
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
FROM php:8.1-%%VARIANT%%
LABEL maintainer="Thomas Bruederli <[email protected]>"
LABEL org.opencontainers.image.source="https://github.com/roundcube/roundcubemail-docker"
# This should be done by the upstream images, but as long as they don't do it,
# we rather use our own hands than suffer from outdated packages.
# Kept as standalone command to make it stand out and be easy to remove.
RUN apt-get update && apt-get -y upgrade && apt-get clean
RUN set -ex; \
if [ "%%VARIANT%%" = "apache" ]; then a2enmod rewrite; fi; \
apt-get update; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get install -y --no-install-recommends \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libldap2-dev \
libmagickwand-dev \
libpng-dev \
libpq-dev \
libsqlite3-dev \
libzip-dev \
libpspell-dev \
libonig-dev \
libldap-common \
; \
# installto.sh & web install dependencies
fetchDeps="gnupg locales libc-l10n"; \
installDeps="aspell aspell-en rsync unzip"; \
apt-get install -y --no-install-recommends \
$installDeps \
$fetchDeps \
; \
\
# Extract sources to avoid using pecl (https://github.com/docker-library/php/issues/374#issuecomment-690698974)
pecl bundle -d /usr/src/php/ext imagick; \
pecl bundle -d /usr/src/php/ext redis; \
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
docker-php-ext-configure gd --with-jpeg --with-freetype; \
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
docker-php-ext-install \
exif \
gd \
intl \
ldap \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
zip \
pspell \
imagick \
redis \
; \
docker-php-ext-enable imagick opcache redis; \
docker-php-source delete; \
rm -r /tmp/pear; \
# Display installed modules
php -m; \
\
# 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 $installDeps $fetchDeps; \
extdir="$(php -r 'echo ini_get("extension_dir");')"; \
ldd "$extdir"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*; \
ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \
ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \
err="$(php --version 3>&1 1>&2 2>&3)"; \
[ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;); \
# include the wait-for-it.sh script (latest commit)
curl -fL https://raw.githubusercontent.com/vishnubob/wait-for-it/81b1373f17855a4dc21156cfe1694c31d7d1792e/wait-for-it.sh -o /wait-for-it.sh; \
chmod +x /wait-for-it.sh;
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# use custom PHP settings
COPY php.ini /usr/local/etc/php/conf.d/roundcube-defaults.ini
COPY --chmod=0755 docker-entrypoint.sh /
# Define Roundcubemail version
ENV ROUNDCUBEMAIL_VERSION %%VERSION%%
# Define the GPG key used for the bundle verification process
ENV ROUNDCUBEMAIL_KEYID "F3E4 C04B B3DB 5D42 15C4 5F7F 5AB2 BAA1 41C4 F7D5"
# Download package and extract to web volume
RUN set -ex; \
curl -o roundcubemail.tar.gz -fSL https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBEMAIL_VERSION}/roundcubemail-${ROUNDCUBEMAIL_VERSION}-complete.tar.gz; \
curl -o roundcubemail.tar.gz.asc -fSL https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBEMAIL_VERSION}/roundcubemail-${ROUNDCUBEMAIL_VERSION}-complete.tar.gz.asc; \
export GNUPGHOME="$(mktemp -d)"; \
curl -fSL https://roundcube.net/download/pubkey.asc -o /tmp/pubkey.asc; \
LC_ALL=C.UTF-8 gpg -n --show-keys --with-fingerprint --keyid-format=long /tmp/pubkey.asc | if [ $(grep -c -o 'Key fingerprint') != 1 ]; then echo 'The key file should contain only one GPG key'; exit 1; fi; \
LC_ALL=C.UTF-8 gpg -n --show-keys --with-fingerprint --keyid-format=long /tmp/pubkey.asc | if [ $(grep -c -o "${ROUNDCUBEMAIL_KEYID}") != 1 ]; then echo 'The key ID should be the roundcube one'; exit 1; fi; \
gpg --batch --import /tmp/pubkey.asc; \
rm /tmp/pubkey.asc; \
gpg --batch --verify roundcubemail.tar.gz.asc roundcubemail.tar.gz; \
gpgconf --kill all; \
mkdir /usr/src/roundcubemail; \
tar -xf roundcubemail.tar.gz -C /usr/src/roundcubemail --strip-components=1 --no-same-owner; \
rm -r "$GNUPGHOME" roundcubemail.tar.gz.asc roundcubemail.tar.gz; \
rm -rf /usr/src/roundcubemail/installer; \
chown -R www-data:www-data /usr/src/roundcubemail/logs; \
# Create the config dir
mkdir -p /var/roundcube/config /var/roundcube/enigma
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["%%CMD%%"]