-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
127 lines (119 loc) · 5.35 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
#
# This file is auto-generated by update.sh
#
# @package php/alpine/fpm
# @author Yannoff <https://github.com/yannoff>
# @license MIT
#
ARG ALPINE_VERSION
FROM php:7.0-fpm-alpine${ALPINE_VERSION}
ARG TZ=UTC
ARG PHP_EXTS="pdo_mysql pdo_pgsql intl opcache bcmath"
ARG APK_BASE="bash git vim"
ARG APK_EXTRA
ARG PHP_LIBS
ARG COMPOSER_VERSION=2.2.18
ARG OFFENBACH_VERSION
ARG OFFENBACH_FILENAME
ARG OFFENBACH_INSTALL_DIR=/usr/bin
LABEL author="Yannoff <https://github.com/yannoff>" \
description="PHP-FPM with basic php extensions and composer" \
license="MIT"
ENV MUSL_LOCPATH /usr/local/share/i18n/locales/musl
# Fix ICONV library implementation
# @see https://github.com/docker-library/php/issues/240
ENV LD_PRELOAD /usr/local/lib/preloadable_libiconv.so
# When the container is run as an unknown user (e.g 1000), COMPOSER_HOME defaults to /.composer
ENV COMPOSER_HOME /.composer
ENV PATH $COMPOSER_HOME/vendor/bin:$PATH
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN \
BUILD_DEPS="autoconf cmake coreutils gcc libc-dev make patch"; \
\
echo -e "\033[01m******************************* Build arguments ******************************\033[00m"; \
echo -e "\033[01;34mTZ:\033[01;33m ${TZ}\033[00m"; \
echo -e "\033[01;34mAPK_BASE:\033[01;33m ${APK_BASE}\033[00m"; \
echo -e "\033[01;34mAPK_EXTRA:\033[01;33m ${APK_EXTRA}\033[00m"; \
echo -e "\033[01;34mPHP_EXTS:\033[01;33m ${PHP_EXTS}\033[00m"; \
echo -e "\033[01;34mPHP_LIBS:\033[01;33m ${PHP_LIBS}\033[00m"; \
echo -e "\033[01;34mCOMPOSER_VERSION:\033[01;33m ${COMPOSER_VERSION}\033[00m"; \
echo -e "\033[01;34mOFFENBACH_VERSION:\033[01;33m ${OFFENBACH_VERSION}\033[00m"; \
echo -e "\033[01;34mOFFENBACH_FILENAME:\033[01;33m ${OFFENBACH_FILENAME}\033[00m"; \
echo -e "\033[01;34mOFFENBACH_INSTALL_DIR:\033[01;33m ${OFFENBACH_INSTALL_DIR}\033[00m"; \
echo -e "\033[01m******************************************************************************\033[00m"; \
\
# Install basic packages
apk add --update tzdata ${APK_BASE} ${APK_EXTRA} && \
\
# Keep a list of installed packages for after-cleanup restore
export installed=$(apk info | xargs); \
\
# Install temporary build dependencies
apk add --no-cache --virtual build-deps ${BUILD_DEPS} && \
\
# Install PHP extensions
install-php-extensions ${PHP_EXTS} && \
\
# Install composer
curl -sSL https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /usr/bin/composer && \
chmod +x /usr/bin/composer && \
echo -ne "\033[01mComposer installed\033[00m: " && \
composer --version && \
\
# Install support for locales
# @see https://github.com/gliderlabs/docker-alpine/issues/144
apk add --no-cache --virtual .locale-run-deps libintl && \
apk add --no-cache --virtual .locale-build-deps cmake make musl-dev gcc gettext-dev && \
cd /tmp && curl --output musl-locales-master.zip https://codeload.github.com/rilian-la-te/musl-locales/zip/master && \
unzip musl-locales-master.zip && cd musl-locales-master; \
cmake . && make && make install; \
cd .. && rm -rf /tmp/musl-locales-master*; \
\
# Fix ICONV library implementation
# @see https://github.com/docker-library/php/issues/240
# (could possibly be replaced by:
# apk add gnu-libiconv --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted; \
# @see https://github.com/wallabag/docker/pull/158/files
# )
apk add --no-cache --virtual .iconv-build-deps file libtool && \
curl -sSL http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz | tar -xz -C . && \
cd libiconv-1.14 && \
./configure --prefix=/usr/local && \
curl -sSL https://raw.githubusercontent.com/mxe/mxe/7e231efd245996b886b501dad780761205ecf376/src/libiconv-1-fixes.patch | patch -p1 -u && \
make && make install && \
libtool --finish /usr/local/lib; \
cd .. && \
rm -rf libiconv-1.14; \
\
# Use VIM for VI (instead of the poorly implemented BusyBox equivalent)
rm /usr/bin/vi && ln -s /usr/bin/vim /usr/bin/vi && \
\
# Configure PHP Runtime & system timezone
{ rm /etc/localtime || true; } && ln -s /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo "[Date]" >> /usr/local/etc/php/conf.d/datetime.ini && \
echo "date.timezone = ${TZ}" >> /usr/local/etc/php/conf.d/datetime.ini && \
\
# Additional PHP Config
echo "[PHAR]" >> /usr/local/etc/php/conf.d/phar.ini && \
echo "phar.readonly = Off" >> /usr/local/etc/php/conf.d/phar.ini && \
\
# Ensure the COMPOSER_HOME directory is accessible to all users
mkdir $COMPOSER_HOME && chmod 0777 $COMPOSER_HOME; \
\
# Install offenbach
url=https://github.com/yannoff/offenbach/releases/latest/download/install.sh && \
curl -SL -s -o - ${url} | bash 2>&1 && \
\
# Install on-demand global PHP packages, if appropriate
if [ -n "${PHP_LIBS}" ]; \
then \
composer global require ${PHP_LIBS}; \
fi; \
# Cleanup:
# - remove build dependencies
# - restore installed packages (avoid collision with build deps)
apk del --no-cache build-deps .locale-build-deps .iconv-build-deps; \
\
# Restore base installed packages, prevents accidental removal by build-deps cleanup
# @see https://github.com/yannoff/docker-php-fpm/issues/28
apk add --no-cache ${installed};