Skip to content

Commit 8790b7d

Browse files
committed
Switch from Arch Linux to Alpine Linux for smaller images.
Official docker images are beginning to migrate to Alpine Linux instead of Arch Linux as it is much better suited for Docker's usecases. The small image sizes and easy configuration make it a preferred distribution for a base. PHP doesn't get as big of a benefit as other environments because of the desire to bundle the PHP source into the image for easy extension installation, but it does still reduce this image from ~600 MB to ~450 MB which helps. This switch to the official PHP image also makes it easier to use this image - utilities for installing/enabling PHP extensions are already included and it increases familiarity for users that have used the official image previously.
1 parent 25df7b6 commit 8790b7d

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

Dockerfile

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
1-
FROM base/archlinux:latest
1+
FROM php:7.0-alpine
22

33
MAINTAINER Spencer Rinehart <[email protected]>
44

5-
RUN curl -o /etc/pacman.d/mirrorlist "https://www.archlinux.org/mirrorlist/?country=all&protocol=https&ip_version=6&use_mirror_status=on" && sed -i 's/^#//' /etc/pacman.d/mirrorlist
6-
7-
# Update system and install php + composer dependencies (git and openssh for
8-
# access to repositories)
9-
RUN pacman-key --refresh-keys && \
10-
pacman --sync --refresh --noconfirm --noprogressbar --quiet && \
11-
pacman --sync --noconfirm --noprogressbar --quiet archlinux-keyring openssl pacman && \
12-
pacman-db-upgrade && \
13-
pacman --sync --sysupgrade --noconfirm --noprogressbar --quiet && \
14-
pacman --sync --noconfirm --noprogressbar --quiet php git openssh
15-
16-
# Configure the base system. Timezone is there to silence php's silly
17-
# warnings.
18-
COPY timezone.ini /etc/php/conf.d/
5+
RUN apk add --no-cache --virtual .php-composer-deps git openssh
196

207
RUN mkdir /code
218
WORKDIR /code
229

23-
ENV HOME /root
2410
ENV COMPOSER_HOME $HOME/.composer
2511

2612
# Setup and install composer into the composer global location. The
2713
# certificate is installed manually to get around open_basedir restrictions.
2814
RUN mkdir -p $COMPOSER_HOME/vendor/bin
29-
RUN curl -sSLo $COMPOSER_HOME/cacert.pem http://curl.haxx.se/ca/cacert.pem
30-
RUN curl -sSL https://getcomposer.org/installer | php -- --install-dir=$COMPOSER_HOME/vendor/bin --filename=composer --cafile=$COMPOSER_HOME/cacert.pem
15+
RUN curl -sSL https://getcomposer.org/installer | \
16+
php -- --install-dir=$COMPOSER_HOME/vendor/bin --filename=composer
3117

3218
# Setup PATH to prioritize local composer bin and global composer bin ahead of
3319
# system PATH.

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
This is a base image for building [PHP][PHP] [composer] packages.
33

44
## Purpose
5-
This docker image builds on top of Arch Linux's base/archlinux image for the
5+
This docker image builds on top of the official PHP 7.0-alpine image with the
66
purpose of building PHP composer packages. It provides several key features:
77

88
* Access to the build location will be in the volume located at `/code`. This
99
directory will be the default working directory.
1010
* Composer bin directories are automatically included in `PATH`. Both a
1111
relative `vendor/bin` directory, and the global `$COMPOSER_HOME/vendor/bin`
1212
directory are included in the `PATH`.
13-
* Timezone set to `UTC` by default to remove the warnings with PHP's date and
14-
time functions. This can be overridden by updating
15-
`/etc/php/conf.d/timezone.ini`.
1613

1714
## Usage
1815
This library is useful with simple `composer.json`'s from the command line.
@@ -73,7 +70,8 @@ process alone could look like this:
7370
```dockerfile
7471
FROM nubs/composer-build
7572

76-
RUN pacman --sync --noconfirm --noprogressbar --quiet xdebug
73+
RUN apk add --no-cache xdebug && \
74+
docker-php-ext-enable xdebug
7775
```
7876

7977
You can then build this docker image and run it against your `composer.json`

timezone.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)