Skip to content

Instantly share code, notes, and snippets.

@rjnienaber
Created October 2, 2017 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjnienaber/707ccd7e1b143f9cbd1424b7bba7ca34 to your computer and use it in GitHub Desktop.
Save rjnienaber/707ccd7e1b143f9cbd1424b7bba7ca34 to your computer and use it in GitHub Desktop.
PHP 5.5 on Alpine Linux
# base for this file taken from here: https://github.com/GitHub30/php/blob/5.5/5.5/alpine/Dockerfile
FROM alpine:3.6
ENV BASE_LINUX alpine
RUN apk add --no-cache --virtual .persistent-deps \
ca-certificates \
curl \
tar \
xz \
apache2 \
dumb-init \
&& rm -rf /var/www/localhost
RUN apk update
RUN apk --no-cache add ca-certificates libgcc
RUN curl https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub > /etc/apk/keys/sgerrand.rsa.pub
RUN curl -L -o /tmp/glibc-2.25-r0.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
RUN curl -L -o /tmp/glibc-i18n-2.25-r1.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/unreleased/glibc-i18n-2.25-r1.apk
RUN curl -L -o /tmp/glibc-bin-2.25-r1.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/unreleased/glibc-bin-2.25-r1.apk
RUN apk add /tmp/glibc-2.25-r0.apk
RUN apk add /tmp/glibc-bin-2.25-r1.apk
RUN apk add /tmp/glibc-i18n-2.25-r1.apk
RUN /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
RUN mkdir -p /run/apache2
RUN mkdir -p /var/run/apache2
RUN mkdir -p /var/lock/apache2
RUN mkdir -p /var/www/html
RUN set -x && adduser -D -S -G www-data www-data
RUN mkdir -p /usr/local/etc/php/conf.d
RUN set -xe \
&& mkdir -p /usr/src \
&& cd /usr/src \
&& curl -fSsL "http://php.net/get/php-5.5.38.tar.xz/from/this/mirror" -o php.tar.xz \
&& echo "cb527c44b48343c8557fe2446464ff1d4695155a95601083e5d1f175df95580f *php.tar.xz" | sha256sum -c - \
&& apk add --no-cache --virtual .build-deps \
autoconf \
file \
g++ \
gcc \
libc-dev \
make \
pkgconf \
re2c \
curl-dev \
libedit-dev \
libxml2-dev \
sqlite-dev \
apache2-dev \
libpng-dev \
bzip2-dev \
gettext-dev \
libmcrypt-dev \
\
&& mkdir -p /usr/src/php \
&& tar -Jxf /usr/src/php.tar.xz -C /usr/src/php --strip-components=1 \
&& cd /usr/src/php \
&& ./configure \
--with-config-file-path=/usr/local/etc/php \
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
\
--disable-cgi \
\
--enable-ftp \
--enable-mbstring \
--enable-opcache \
--enable-bcmath \
--enable-dba=shared \
--enable-exif \
--enable-zip \
--enable-shmop \
--enable-calendar \
--enable-soap \
\
--with-curl \
--with-libedit \
--with-openssl \
--with-zlib \
--with-apxs2=/usr/bin/apxs \
--with-gd \
--with-mhash \
--with-bz2 \
--with-gettext \
--with-mcrypt \
--with-mysql \
\
&& make -j"$(getconf _NPROCESSORS_ONLN)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \
&& make clean \
&& rm -rf /usr/src/php \
&& rm /usr/src/php.tar.xz \
\
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache --virtual .php-rundeps $runDeps \
\
&& apk del .build-deps
COPY conf/httpd.conf /etc/apache2/httpd.conf
COPY conf/default.conf /etc/apache2/conf.d/default.conf
COPY conf/php.ini /usr/local/etc/php/php.ini
ENTRYPOINT ["/usr/sbin/httpd", "-D", "FOREGROUND", "-f", "/etc/apache2/httpd.conf"]
EXPOSE 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment