Skip to content

Commit 3a060dc

Browse files
committed
Added support for build arguments
* Added `COMPOSER_VERSION` argument in all `Dockerfile` to specify which composer version to install (default to `latest` in Dockerfile, `1` in `Makefile`) * Added `XDEBUG_VERSION` argument in all `Dockerfile` to specify which version of `xdebug` to install * Changed the way composer is installed in images by using `COPY --from=composer:${COMPOSER_VERSION} /usr/bin/composer /usr/bin/composer` * Changed path of composer executable from `/usr/local/bin/composer` to `/usr/bin/composer`
1 parent 85dcffc commit 3a060dc

File tree

11 files changed

+147
-66
lines changed

11 files changed

+147
-66
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.2.5] - 2020-10-24
10+
### Added
11+
- Added `COMPOSER_VERSION` argument in all `Dockerfile` to specify which composer version to install (default to `latest` in Dockerfile, `1` in `Makefile`)
12+
- Added `XDEBUG_VERSION` argument in all `Dockerfile` to specify which version of `xdebug` to install
13+
14+
### Changes
15+
- Changed the way composer is installed in images by using `COPY --from=composer:${COMPOSER_VERSION} /usr/bin/composer /usr/bin/composer`
16+
- Changed path of composer executable from `/usr/local/bin/composer` to `/usr/bin/composer`
17+
18+
### Fixed
19+
- Fixed unused `PRESTISSIMO_VERSION` argument during build
20+
- Removed `docker-php-ext-install` instruction for already installed extensions (like `pdo`, `iconv`, `mbstring`)
21+
922
## [1.2.4] - 2020-09-14
1023
### Fixed
1124
- Fixed `ImagickException: attempt to perform an operation not allowed by the security policy 'PDF' @ error/constitute.c/IsCoderAuthorized/408` error when trying to read a PDF with Imagick extension.

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
REPOSITORY?=jsunier/php-symfony-test
22
BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%m:%SZ")"
33
PRESTISSIMO_VERSION=0.3.10
4+
COMPOSER_VERSION=1
45
VERSIONS=7.4 7.3 7.2 7.1
56
LATEST_VERSION=7.4
67

8+
.PHONY: build
9+
build: build-mysql build-postgresql
10+
711
.PHONY: build-mysql
812
build-mysql:
913
for VERSION in $(VERSIONS); do \
10-
docker build php$$VERSION/mysql --build-arg PRESTISSIMO_VERSION=$$PRESTISSIMO_VERSION --build-arg BUILD_DATE=$$BUILD_DATE -t $(REPOSITORY):php$$VERSION-mysql -t $(REPOSITORY):php$$VERSION-mariadb; \
14+
docker build php$$VERSION/mysql --build-arg PRESTISSIMO_VERSION=$(PRESTISSIMO_VERSION) --build-arg BUILD_DATE=$(BUILD_DATE) --build-arg COMPOSER_VERSION=$(COMPOSER_VERSION) -t $(REPOSITORY):php$$VERSION-mysql -t $(REPOSITORY):php$$VERSION-mariadb; \
1115
done
12-
docker build php${LATEST_VERSION}/mysql --build-arg PRESTISSIMO_VERSION=$$PRESTISSIMO_VERSION --build-arg BUILD_DATE=$$BUILD_DATE -t $(REPOSITORY):latest -t $(REPOSITORY):latest-mysql
16+
docker build php${LATEST_VERSION}/mysql --build-arg PRESTISSIMO_VERSION=$(PRESTISSIMO_VERSION) --build-arg BUILD_DATE=$(BUILD_DATE) --build-arg COMPOSER_VERSION=$(COMPOSER_VERSION) -t $(REPOSITORY):latest -t $(REPOSITORY):latest-mysql
1317

1418
.PHONY: build-postgresql
1519
build-postgresql:
1620
for VERSION in $(VERSIONS); do \
17-
docker build php$$VERSION/postgresql --build-arg PRESTISSIMO_VERSION=$$PRESTISSIMO_VERSION --build-arg BUILD_DATE=$$BUILD_DATE -t $(REPOSITORY):php$$VERSION-postgresql; \
21+
docker build php$$VERSION/postgresql --build-arg PRESTISSIMO_VERSION=$(PRESTISSIMO_VERSION) --build-arg BUILD_DATE=$(BUILD_DATE) --build-arg COMPOSER_VERSION=$(COMPOSER_VERSION) -t $(REPOSITORY):php$$VERSION-postgresql; \
1822
done
19-
docker build php${LATEST_VERSION}/postgresql --build-arg PRESTISSIMO_VERSION=$$PRESTISSIMO_VERSION --build-arg BUILD_DATE=$$BUILD_DATE -t $(REPOSITORY):latest-postgresql
23+
docker build php${LATEST_VERSION}/postgresql --build-arg PRESTISSIMO_VERSION=$(PRESTISSIMO_VERSION) --build-arg BUILD_DATE=$(BUILD_DATE) --build-arg COMPOSER_VERSION=$(COMPOSER_VERSION) -t $(REPOSITORY):latest-postgresql
2024

2125
.PHONY: pull-php
2226
pull-php:
2327
for VERSION in $(VERSIONS); do \
2428
docker pull php:$$VERSION-cli; \
2529
done
2630
docker pull php:latest
31+
docker pull composer:${COMPOSER_VERSION}
32+
33+
.PHONY: push
34+
push: push-mysql push-postgresql
2735

2836
.PHONY: push-mysql
2937
push-mysql:

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For now, there is only two available database adapters for the available PHP ver
3232

3333
Every images include the latest version of [composer](https://getcomposer.org) installed at `/usr/local/bin/composer`.
3434

35-
Composer is installed with [hirak/prestissimo](https://packagist.org/packages/hirak/prestissimo) to speed up packages installation.
35+
Composer is installed with [hirak/prestissimo](https://packagist.org/packages/hirak/prestissimo) plugin to speed up packages installation.
3636

3737
List of PHP extensions installed:
3838

@@ -54,6 +54,14 @@ List of PHP extensions installed:
5454
| `oci8` |||||
5555
| `redis` |||||
5656

57+
## Examples
58+
59+
### Docker run
60+
61+
```
62+
$ docker run -it -v $(pwd):/app jsunier/php-symfony-test:php7.4-mysql /bin/bash
63+
```
64+
5765
# Default configurations
5866

5967
Default value in Dockerfile's directives:
@@ -72,18 +80,30 @@ Images are compiled for these architectures:
7280

7381
# Build
7482

75-
## All at once
76-
7783
There is a `Makefile` available to simplify the creation of theses images.
7884

7985
You can change the values inside this file to set your custom repository, folders, tags, etc.
8086

8187
> You need to have `make` installed (`sudo apt install make`)
8288
89+
## Pull all latest source images
90+
91+
```
92+
$ make pull-php
93+
```
94+
95+
## All at once
96+
8397
```
8498
$ make all
8599
```
86100

101+
### Build all (mysql/postgresql)
102+
103+
```
104+
$ make build
105+
```
106+
87107
### Build images with MySQL/MariaDB support
88108

89109
```

php7.1/mysql/Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1+
ARG COMPOSER_VERSION=latest
2+
3+
FROM composer:${COMPOSER_VERSION} as composer_image
4+
15
FROM php:7.1-cli
26

37
ARG BUILD_DATE
4-
ARG PRESTISSIMO_VERSION
8+
ARG PRESTISSIMO_VERSION=0.3.10
9+
ARG XDEBUG_VERSION=2.6.1
510

611
LABEL maintainer="Joël Sunier <[email protected]>" \
712
php.version="7.1" \
813
php.pdo_connector="MySQL" \
14+
php.xdebug_version=${XDEBUG_VERSION} \
915
org.label-schema.build-date=${BUILD_DATE}
1016

1117
RUN apt-get update && apt-get install -yqq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev libxml2-dev libmagickwand-dev libpq-dev libwebp-dev unzip && \
12-
docker-php-ext-install mbstring pdo pdo_mysql zip iconv opcache bcmath sockets soap && \
18+
docker-php-ext-install mbstring pdo_mysql zip opcache bcmath sockets soap && \
1319
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ && \
1420
docker-php-ext-install gd && \
15-
pecl install imagick xdebug-2.6.1 redis && \
21+
pecl install imagick xdebug-${XDEBUG_VERSION} redis && \
1622
docker-php-ext-enable imagick xdebug redis && \
1723
apt-get clean
1824

1925
COPY php.ini $PHP_INI_DIR/php.ini
20-
21-
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
26+
COPY --from=composer_image /usr/bin/composer /usr/bin/composer
2227

2328
WORKDIR /app
2429

@@ -28,14 +33,14 @@ RUN groupadd --gid 1000 symfony \
2833

2934
# Fix permissions issues
3035
RUN chmod -R a+wrx /app
31-
RUN chmod a+wrx /usr/local/bin/composer
36+
RUN chmod a+wrx /usr/bin/composer
3237

3338
# Fix Imagick rights for PDF
3439
RUN rm /etc/ImageMagick-6/policy.xml
3540

3641
VOLUME [ "/app" ]
3742

3843
USER symfony
39-
RUN composer global require --no-interaction --no-progress hirak/prestissimo:0.3.10
44+
RUN composer global require --no-interaction --no-progress hirak/prestissimo:$PRESTISSIMO_VERSION
4045

4146
CMD [ "/app/bin/console" ]

php7.1/postgresql/Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1+
ARG COMPOSER_VERSION=latest
2+
3+
FROM composer:${COMPOSER_VERSION} as composer_image
4+
15
FROM php:7.1-cli
26

37
ARG BUILD_DATE
4-
ARG PRESTISSIMO_VERSION
8+
ARG PRESTISSIMO_VERSION=0.3.10
9+
ARG XDEBUG_VERSION=2.6.1
510

611
LABEL maintainer="Joël Sunier <[email protected]>" \
712
php.version="7.1" \
813
php.pdo_connector="PostgreSQL" \
14+
php.xdebug_version=${XDEBUG_VERSION} \
915
org.label-schema.build-date=${BUILD_DATE}
1016

1117
RUN apt-get update && apt-get install -yqq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev libxml2-dev libmagickwand-dev libpq-dev libwebp-dev unzip && \
1218
docker-php-ext-install mbstring pdo_pgsql zip iconv opcache bcmath sockets soap && \
1319
docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \
1420
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ && \
15-
docker-php-ext-install pdo pdo_pgsql pgsql gd && \
16-
pecl install imagick xdebug-2.6.1 redis && \
21+
docker-php-ext-install pdo_pgsql pgsql gd && \
22+
pecl install imagick xdebug-${XDEBUG_VERSION} redis && \
1723
docker-php-ext-enable imagick xdebug redis && \
1824
apt-get clean
1925

2026
COPY php.ini $PHP_INI_DIR/php.ini
21-
22-
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
27+
COPY --from=composer_image /usr/bin/composer /usr/bin/composer
2328

2429
WORKDIR /app
2530

@@ -29,14 +34,14 @@ RUN groupadd --gid 1000 symfony \
2934

3035
# Fix permissions issues
3136
RUN chmod -R a+wrx /app
32-
RUN chmod a+wrx /usr/local/bin/composer
37+
RUN chmod a+wrx /usr/bin/composer
3338

3439
# Fix Imagick rights for PDF
3540
RUN rm /etc/ImageMagick-6/policy.xml
3641

3742
VOLUME [ "/app" ]
3843

3944
USER symfony
40-
RUN composer global require --no-interaction --no-progress hirak/prestissimo:0.3.10
45+
RUN composer global require --no-interaction --no-progress hirak/prestissimo:$PRESTISSIMO_VERSION
4146

4247
CMD [ "/app/bin/console" ]

php7.2/mysql/Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1+
ARG COMPOSER_VERSION=latest
2+
3+
FROM composer:${COMPOSER_VERSION} as composer_image
4+
15
FROM php:7.2-cli
26

37
ARG BUILD_DATE
4-
ARG PRESTISSIMO_VERSION
8+
ARG PRESTISSIMO_VERSION=0.3.10
9+
ARG XDEBUG_VERSION=2.9.8
510

611
LABEL maintainer="Joël Sunier <[email protected]>" \
712
php.version="7.2" \
813
php.pdo_connector="MySQL" \
14+
php.xdebug_version=${XDEBUG_VERSION} \
915
org.label-schema.build-date=${BUILD_DATE}
1016

1117
RUN apt-get update && apt-get install -yqq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev libxml2-dev libmagickwand-dev libpq-dev libwebp-dev unzip && \
12-
docker-php-ext-install mbstring pdo pdo_mysql zip iconv opcache bcmath sockets soap && \
18+
docker-php-ext-install pdo_mysql zip opcache bcmath sockets soap && \
1319
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ && \
1420
docker-php-ext-install gd && \
15-
pecl install imagick xdebug-2.6.1 redis && \
21+
pecl install imagick xdebug-${XDEBUG_VERSION} redis && \
1622
docker-php-ext-enable imagick xdebug redis && \
1723
apt-get clean
1824

1925
COPY php.ini $PHP_INI_DIR/php.ini
20-
21-
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
26+
COPY --from=composer_image /usr/bin/composer /usr/bin/composer
2227

2328
WORKDIR /app
2429

@@ -28,14 +33,14 @@ RUN groupadd --gid 1000 symfony \
2833

2934
# Fix permissions issues
3035
RUN chmod -R a+wrx /app
31-
RUN chmod a+wrx /usr/local/bin/composer
36+
RUN chmod a+wrx /usr/bin/composer
3237

3338
# Fix Imagick rights for PDF
3439
RUN rm /etc/ImageMagick-6/policy.xml
3540

3641
VOLUME [ "/app" ]
3742

3843
USER symfony
39-
RUN composer global require --no-interaction --no-progress hirak/prestissimo:0.3.10
44+
RUN composer global require --no-interaction --no-progress hirak/prestissimo:$PRESTISSIMO_VERSION
4045

4146
CMD [ "/app/bin/console" ]

php7.2/postgresql/Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1+
ARG COMPOSER_VERSION=latest
2+
3+
FROM composer:${COMPOSER_VERSION} as composer_image
4+
15
FROM php:7.2-cli
26

37
ARG BUILD_DATE
4-
ARG PRESTISSIMO_VERSION
8+
ARG PRESTISSIMO_VERSION=0.3.10
9+
ARG XDEBUG_VERSION=2.9.8
510

611
LABEL maintainer="Joël Sunier <[email protected]>" \
712
php.version="7.2" \
813
php.pdo_connector="PostgreSQL" \
14+
php.xdebug_version=${XDEBUG_VERSION} \
915
org.label-schema.build-date=${BUILD_DATE}
1016

1117
RUN apt-get update && apt-get install -yqq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev libxml2-dev libmagickwand-dev libpq-dev libwebp-dev unzip && \
12-
docker-php-ext-install mbstring pdo_pgsql zip iconv opcache bcmath sockets soap && \
18+
docker-php-ext-install zip opcache bcmath sockets soap && \
1319
docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \
1420
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ && \
15-
docker-php-ext-install pdo pdo_pgsql pgsql gd && \
16-
pecl install imagick xdebug-2.6.1 redis && \
21+
docker-php-ext-install pdo_pgsql pgsql gd && \
22+
pecl install imagick xdebug-${XDEBUG_VERSION} redis && \
1723
docker-php-ext-enable imagick xdebug redis && \
1824
apt-get clean
1925

2026
COPY php.ini $PHP_INI_DIR/php.ini
21-
22-
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
27+
COPY --from=composer_image /usr/bin/composer /usr/bin/composer
2328

2429
WORKDIR /app
2530

@@ -29,14 +34,14 @@ RUN groupadd --gid 1000 symfony \
2934

3035
# Fix permissions issues
3136
RUN chmod -R a+wrx /app
32-
RUN chmod a+wrx /usr/local/bin/composer
37+
RUN chmod a+wrx /usr/bin/composer
3338

3439
# Fix Imagick rights for PDF
3540
RUN rm /etc/ImageMagick-6/policy.xml
3641

3742
VOLUME [ "/app" ]
3843

3944
USER symfony
40-
RUN composer global require --no-interaction --no-progress hirak/prestissimo:0.3.10
45+
RUN composer global require --no-interaction --no-progress hirak/prestissimo:$PRESTISSIMO_VERSION
4146

4247
CMD [ "/app/bin/console" ]

php7.3/mysql/Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1+
ARG COMPOSER_VERSION=latest
2+
3+
FROM composer:${COMPOSER_VERSION} as composer_image
4+
15
FROM php:7.3-cli
26

37
ARG BUILD_DATE
4-
ARG PRESTISSIMO_VERSION
8+
ARG PRESTISSIMO_VERSION=0.3.10
9+
ARG XDEBUG_VERSION=2.9.8
510

611
LABEL maintainer="Joël Sunier <[email protected]>" \
712
php.version="7.3" \
813
php.pdo_connector="MySQL" \
14+
php.xdebug_version=${XDEBUG_VERSION} \
915
org.label-schema.build-date=${BUILD_DATE}
1016

1117
RUN apt-get update && apt-get install -yqq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev libxml2-dev libmagickwand-dev libpq-dev libzip-dev libwebp-dev unzip && \
12-
docker-php-ext-install mbstring pdo pdo_mysql zip iconv opcache bcmath sockets soap && \
18+
docker-php-ext-install pdo_mysql zip opcache bcmath sockets soap && \
1319
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ && \
1420
docker-php-ext-install gd && \
15-
pecl install imagick xdebug-2.7.1 redis && \
21+
pecl install imagick xdebug-${XDEBUG_VERSION} redis && \
1622
docker-php-ext-enable imagick xdebug redis && \
1723
apt-get clean
1824

1925
COPY php.ini $PHP_INI_DIR/php.ini
20-
21-
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
26+
COPY --from=composer_image /usr/bin/composer /usr/bin/composer
2227

2328
WORKDIR /app
2429

@@ -28,14 +33,14 @@ RUN groupadd --gid 1000 symfony \
2833

2934
# Fix permissions issues
3035
RUN chmod -R a+wrx /app
31-
RUN chmod a+wrx /usr/local/bin/composer
36+
RUN chmod a+wrx /usr/bin/composer
3237

3338
# Fix Imagick rights for PDF
3439
RUN rm /etc/ImageMagick-6/policy.xml
3540

3641
VOLUME [ "/app" ]
3742

3843
USER symfony
39-
RUN composer global require --no-interaction --no-progress hirak/prestissimo:0.3.10
44+
RUN composer global require --no-interaction --no-progress hirak/prestissimo:$PRESTISSIMO_VERSION
4045

4146
CMD [ "/app/bin/console" ]

0 commit comments

Comments
 (0)