Skip to content

Commit cd3fb9d

Browse files
authored
Merge pull request #3 from grimzy/php-fpm
PHP FPM
2 parents 3b0426b + 829a98f commit cd3fb9d

File tree

6 files changed

+101
-36
lines changed

6 files changed

+101
-36
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ Refer to master branch
1010

1111
## \[v1.1.1\] - 2019-10-13
1212

13-
### Split PHP builds:
13+
### Split PHP builds, PHP FPM:
1414
- Split builds by PHP version and variant
1515
- Use builds Docker hooks in Makefile
16+
- Added `fpm` variant
17+
- Now using `DOCKER_REPO` and `DOCKER_TAG` build variables
1618

1719
## \[v1.1.0\] - 2019-10-13
1820

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# SOURCE_BRANCH
2-
SOURCE_BRANCH=1.1.0
2+
SOURCE_BRANCH=1.1.1
33

4-
# DOCKER_TAG
4+
# DOCKER_REPO and DOCKER_TAG:
5+
# https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks
6+
DOCKER_REPO=jestefane/php-dev
57
DOCKER_TAG=
68

79
# Possible versions: 5.5 5.6 7.0 7.1 7.2
810
PHP_VERSIONS=5.5 5.6 7.0 7.1 7.2
911

1012
# Possible VARIANT: cli, fpm, apache, alpine
11-
PHP_VARIANTS=cli
13+
PHP_VARIANTS=cli fpm
1214

1315
BIN_DIR=/usr/local/bin
1416
SCRIPTS_DIR=scripts
@@ -18,6 +20,7 @@ build:
1820
@PHP_VERSIONS="$(PHP_VERSIONS)" \
1921
PHP_VARIANTS="$(PHP_VARIANTS)" \
2022
SOURCE_BRANCH="$(SOURCE_BRANCH)" \
23+
DOCKER_REPO="$(DOCKER_REPO)" \
2124
DOCKER_TAG="$(DOCKER_TAG)" \
2225
./build/hooks/build
2326

@@ -26,6 +29,7 @@ post_push:
2629
@PHP_VERSIONS="$(PHP_VERSIONS)" \
2730
PHP_VARIANTS="$(PHP_VARIANTS)" \
2831
SOURCE_BRANCH="$(SOURCE_BRANCH)" \
32+
DOCKER_REPO="$(DOCKER_REPO)" \
2933
DOCKER_TAG="$(DOCKER_TAG)" \
3034
./build/hooks/post_push
3135

@@ -34,7 +38,7 @@ rm_build:
3438
@{ \
3539
for php_version in $(PHP_VERSIONS); do \
3640
for php_variant in $(PHP_VARIANTS); do \
37-
image_name=jestefane/php-dev:$$php_version-$$php_variant-$(SOURCE_BRANCH); \
41+
image_name=$(DOCKER_REPO):$$php_version-$$php_variant-$(SOURCE_BRANCH); \
3842
echo Removing image: $$image_name; \
3943
docker rmi $$image_name || true; \
4044
done; \
@@ -53,7 +57,7 @@ scripts: rm_scripts_dir
5357
regex=s!%%PHP_VERSION%%!$$php_version!g\;s!%%PHP_VARIANT%%!$$php_variant!g\;s!%%SOURCE_BRANCH%%!$(SOURCE_BRANCH)!g; \
5458
mkdir -p $(SCRIPTS_DIR); \
5559
echo ">>> Script: PHP $$php_version-$$php_variant"; \
56-
sed $$regex template/php-cli.template > $(SCRIPTS_DIR)/php-$$php_version-$$php_variant; \
60+
sed $$regex template/php.template > $(SCRIPTS_DIR)/php-$$php_version-$$php_variant; \
5761
done; \
5862
echo ">>> Script Composer $$php_version"; \
5963
sed $$regex template/composer.template > $(SCRIPTS_DIR)/composer-$$php_version; \
@@ -93,5 +97,3 @@ rm_dangling:
9397
@docker volume ls -qf dangling=true | xargs docker volume rm
9498
@echo Removing dangling images
9599
@docker images -qf dangling=true | xargs docker rmi
96-
97-
#TODO: aliasing shortcuts to get the defaults php php-fpm and composer

README.md

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# PHP Development Docker Images
1+
#### PHP Development Docker Images
22

3-
![Docker Cloud Automated build][docker-cloud-automated] ![Docker Cloud Build Status][docker-cloud-build] ![Docker Pulls][docker-pulls] ![Docker Stars][docker-stars] ![MicroBadger Layers][microbadger-layers] ![MicroBadger Size][microbadger-image-size]
3+
[![Docker Cloud Automated build][docker-cloud-automated]][docker-builds] [![Docker Cloud Build Status][docker-cloud-build]][docker-builds] [![Docker Pulls][docker-pulls]][docker-overview] [![Docker Stars][docker-stars]][docker-overview] [![MicroBadger Layers][microbadger-layers]][docker-overview] [![MicroBadger Size][microbadger-image-size]][docker-overview]
44

55
> Super simple Docker images for PHP development.
66
77
**PHP Versions:** `5.5`, `5.6`, `7.0`, `7.1`, `7.2`
88

9-
**PHP Variants:** `cli`
9+
**PHP Variants:** `cli`, `fpm`
1010

1111
**Images based on the** [Official PHP Images][docker-php]
1212

@@ -26,7 +26,7 @@ $ docker pull jestefane/php-dev
2626
**Pull a specific version:**
2727

2828
```sh
29-
$ docker pull jestefane/php-dev:7.2-cli-1.1.0
29+
$ docker pull jestefane/php-dev:7.2-cli-1.1.1
3030
```
3131

3232
Pick between the various [images provided in this repository][images].
@@ -47,23 +47,44 @@ To use the Docker images more like binaries, we're providing [Shortcuts][shortcu
4747
4848
**Images names**:
4949
50-
- `jestefane/php-dev:5.5-cli-1.1.0`
51-
- `jestefane/php-dev:5.6-cli-1.1.0`
52-
- `jestefane/php-dev:7.0-cli-1.1.0`
53-
- `jestefane/php-dev:7.1-cli-1.1.0`
54-
- `jestefane/php-dev:7.2-cli-1.1.0`
50+
- `jestefane/php-dev:5.5-cli-1.1.1`
51+
- `jestefane/php-dev:5.6-cli-1.1.1`
52+
- `jestefane/php-dev:7.0-cli-1.1.1`
53+
- `jestefane/php-dev:7.1-cli-1.1.1`
54+
- `jestefane/php-dev:7.2-cli-1.1.1`
5555
5656
**Shortcuts**: [`php-cli`][php-cli-ref], [`composer`][composer-ref]
5757
5858
**Example**:
5959
6060
```bash
61-
$ docker run jestefane/php-dev:7.2-cli-1.1.0 hello-world.php
61+
$ docker run jestefane/php-dev:7.2-cli-1.1.1 hello-world.php
6262
6363
# or using one of the provided shortcuts
6464
$ php-7.2-cli hello-world.php
6565
```
6666
67+
### FPM
68+
69+
**Images names**:
70+
71+
- `jestefane/php-dev:5.5-fpm-1.1.1`
72+
- `jestefane/php-dev:5.6-fpm-1.1.1`
73+
- `jestefane/php-dev:7.0-fpm-1.1.1`
74+
- `jestefane/php-dev:7.1-fpm-1.1.1`
75+
- `jestefane/php-dev:7.2-fpm-1.1.1`
76+
77+
**Shortcuts**: [`php-fpm`][php-fpm-ref]
78+
79+
**Example**:
80+
81+
```bash
82+
$ docker run jestefane/php-dev:7.2-fpm-1.1.1 hello-world.php
83+
84+
# or using one of the provided shortcuts
85+
$ php-7.2-fpm hello-world.php
86+
```
87+
6788
## Shortcuts
6889

6990
> **Note**: Only tested on some distros of Linux and Mac OS. But hey! It's tested ;)
@@ -90,6 +111,20 @@ This generates `bash` scripts in the `scripts` directory (via. [Script Template]
90111

91112
For more info on the `shortcuts` task, please checkout the [Makefile command reference][shortcuts-make].
92113

114+
#### Aliasing your Preferred Version Shortucts
115+
116+
Optionally, you can alias your preferred shortcuts by adding them to your `~/.bash_profile`:
117+
118+
```sh
119+
# Aliases for the jestefane/php-dev preferred versions
120+
alias php="php-7.2-cli"
121+
alias composer="composer-7.2"
122+
```
123+
124+
> **Note**: this is not a perfect replacement for installing PHP on your system.
125+
126+
> After saving your `.bash_profile`, don't forget to source your changes (`. ~/.bash_profile`) for them to take effect. Alternatively open a new Terminal session.
127+
93128
#### Script Templates
94129

95130
You'll notice that the directory that should contain the scripts doesn't exist; that's because you first need to generate them. This is automatically done prior to creating the symlinks. But if you've deleted a script or changed the templates in some way, you can regenerate scripts with:
@@ -105,48 +140,58 @@ For more info on the `scripts` task [Makefile command reference][scripts-make].
105140

106141
#### PHP CLI
107142

108-
**Images**: [All respective versions of the PHP CLI variant][cli]
143+
Images: [All respective versions of the PHP CLI variant][cli]
144+
145+
Shortcuts: `php-5.5-cli`, `php-5.6-cli`, `php-7.0-cli`, `php-7.1-cli`, `php-7.2-cli`
109146

110-
**Shortcuts**: `php-5.5-cli`, `php-5.6-cli`, `php-7.0-cli`, `php-7.1-cli`, `php-7.2-cli`
147+
Script template: [template/php.template][php-template]
111148

112-
**Script template**: [template/php-cli.template][php-cli-template]
149+
#### PHP FPM
150+
151+
Images: [All respective versions of the PHP FPM variant][fpm]
152+
153+
Shortcuts: `php-5.5-fpm`, `php-5.6-fpm`, `php-7.0-fpm`, `php-7.1-fpm`, `php-7.2-fpm`
154+
155+
Script template: [template/php.template][php-template]
113156

114157
#### Composer
115158

116-
**Images**: [All respective versions of `jestefane/php-dev` images][images] ([Composer][composer] is installed on every image)
159+
Images: [All respective versions of `jestefane/php-dev` images][images] ([Composer][composer] is installed on every image)
117160

118-
**Shortcuts**: `composer-5.5`, `composer-5.6`, `composer-7.0`, `composer-7.1`, `composer-7.2`
161+
Shortcuts: `composer-5.5`, `composer-5.6`, `composer-7.0`, `composer-7.1`, `composer-7.2`
119162

120-
**Script template**: [template/composer.template][composer-template]
163+
Script template: [template/composer.template][composer-template]
121164

122165
## Makefile Commands Reference
123166

124167
### Variables
125168

126169
| Variable name | Description | Default value | Possible values |
127170
| --------------- | ------------------------------------------------------------ | ------------------------------------- | ------------------------------------------------------------ |
128-
| `SOURCE_BRANCH` | Appended to the image name | Repository's current version: `1.1.0` | Any `string` value |
171+
| `SOURCE_BRANCH` | Appended to the image name | Repository's current version: `1.1.1` | Any `string` value |
172+
| `DOCKER_REPO` | The Dockerhub repository to perform the tasks against | `jestefane/php-dev` | A Dockerhub repository |
173+
| `DOCKER_TAG` | A combinaison of one PHP version and one PHP variant to perform a task only one image (for example `7.1-cli`) | Empty | Any `PHP_VERSION`-`PHP_VARIANT` combinaison |
129174
| `PHP_VERSIONS` | Space separated list of PHP versions to perform a task on | `5.5 5.6 7.0 7.1 7.2` | Any combination from `5.5`, `5.6`, `7.0`, `7.1`, `7.2` |
130-
| `PHP_VARIANTS` | Space separated list of Docker build variants to perform a task on | `cli` | `cli` |
175+
| `PHP_VARIANTS` | Space separated list of Docker build variants to perform a task on | `cli fpm` | `cli`, `fpm` |
131176
| `BIN_DIR` | Directory in your `PATH` where you would like to symlink the scripts | `/usr/local/bin` | Any path on your system. Preferaby one already in your `PATH` |
132177
| `SCRIPTS_DIR` | Directory where the scripts are generated (or removed). Relative to the repository's root | `scripts` | Any path on your system |
133178

134179
> **Note**: When overriding space separated values from the CLI, you have to escape spaces. For example in `bash` you use `\`:
135180
>
136181
> ```sh
137-
> $ make build PHP_VERSIONS=7.0\ 7.1\ 7.2
182+
> $ make build PHP_VERSIONS=7.0\ 7.1\ 7.2 PHP_VARIANTS=cli\ fpm
138183
> ```
139184
140185
### Tasks
141186
142187
#### Build the Images
143188
144-
Locally builds all images from all possible combinations of `PHP_VERSIONS` and `PHP_VARIANTS`. `SOURCE_BRANCH` is appended to the image name.
189+
Locally builds all images from all possible combinations of `PHP_VERSIONS` and `PHP_VARIANTS`. `SOURCE_BRANCH` is appended to the image name. The `DOCKER_TAG` is used to target a specific PHP version and variant.
145190
146191
**Command:**
147192
148193
```sh
149-
$ make build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=]
194+
$ make build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [DOCKER_TAG=] [DOCKER_REPO=]
150195
```
151196
152197
#### Remove the Images
@@ -156,7 +201,7 @@ Remove all locally cached images from all possible combinations of `PHP_VERSIONS
156201
**Command:**
157202

158203
```sh
159-
$ make rm_build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=]
204+
$ make rm_build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [DOCKER_REPO=]
160205
```
161206

162207
#### Rebuild the Images
@@ -209,6 +254,18 @@ This task removes this repository's scripts' symlinks from the `BIN_DIR`.
209254
$ make rm_shortcuts [PHP_VERSIONS=] [PHP_VARIANTS=] [BIN_DIR=]
210255
```
211256

257+
#### Post Push
258+
259+
Pushes the images to Dockerhub.
260+
261+
> Truly, only used when developing to make sure that the Autobuild `post_push` hook works properly.
262+
263+
**Command:**
264+
265+
```sh
266+
make post_push [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [DOCKER_TAG=] [DOCKER_REPO=]
267+
```
268+
212269
#### Remove Dangling Volumes and Images
213270

214271
> **Warning**: Running this task will remove **any** dangling volume and image on your system; not just the ones provided.
@@ -228,19 +285,23 @@ $ make rm_dangling
228285
[docker-cloud-build]: https://img.shields.io/docker/cloud/build/jestefane/php-dev "Docker Cloud Build Status"
229286
[docker-pulls]: https://img.shields.io/docker/pulls/jestefane/php-dev "Docker Pulls"
230287
[docker-stars]: https://img.shields.io/docker/stars/jestefane/php-dev "Docker Stars"
231-
[microbadger-layers]: https://img.shields.io/microbadger/layers/jestefane/php-dev/7.2-cli-args-in-build "MicroBadger Layers"
232-
[microbadger-image-size]: https://img.shields.io/microbadger/image-size/jestefane/php-dev/7.2-cli-1.1.0 "MicroBadger Size"
288+
[docker-builds]: https://hub.docker.com/r/jestefane/php-dev/builds "Docker Builds"
289+
[docker-overview]: https://hub.docker.com/r/jestefane/php-dev "Docker Overview"
290+
[microbadger-layers]: https://img.shields.io/microbadger/layers/jestefane/php-dev/7.2-cli-1.1.1 "MicroBadger Layers"
291+
[microbadger-image-size]: https://img.shields.io/microbadger/image-size/jestefane/php-dev/7.2-cli-1.1.1 "MicroBadger Size"
233292
[shortcuts]: #shortcuts "Shortcuts"
234293
[install-the-shortcuts]: #install-the-shortcuts "Install the Shortcuts"
235294
[docker-php]: https://hub.docker.com/_/php "Official Docker PHP Images"
236295
[images]: #images "PHP Images"
237296
[cli]: #cli "PHP CLI Image"
238297
[php-cli-ref]: #php-cli "PHP CLI Scripts"
239-
[php-cli-template]: template/php-cli.template "PHP CLI Template"
298+
[php-template]: template/php.template "PHP Template"
299+
[fpm]: #fpm "PHP FPM Image"
300+
[php-fpm-ref]: #php-fpm "PHP FPM Scripts"
240301
[composer]: https://getcomposer.org/ "Composer"
241302
[composer-template]: template/composer.template "Composer Template"
242303
[composer-ref]: #composer "PHP Composer Scripts"
243304
[templates]: #script-templates "Script Templates"
244305
[shortcuts-make]: #create-the-shortcuts "Create the Shortcuts"
245306
[scripts-make]: #generate-the-scripts "Generate the Scripts"
246-
[license]: ./LICENSE "MIT License"
307+
[license]: ./LICENSE "MIT License File"

build/hooks/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ for php_version in $PHP_VERSIONS; do
1212
xdebug_version=-2.5.5
1313
fi;
1414
for php_variant in $PHP_VARIANTS; do
15-
image_name="jestefane/php-dev:$php_version-$php_variant-$SOURCE_BRANCH"
15+
image_name="$DOCKER_REPO:$php_version-$php_variant-$SOURCE_BRANCH"
1616
echo "Building image: $image_name"
1717
docker build \
1818
-t "$image_name" \

build/hooks/post_push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
77

88
for php_version in $PHP_VERSIONS; do
99
for php_variant in $PHP_VARIANTS; do
10-
image_name="jestefane/php-dev:$php_version-$php_variant-$SOURCE_BRANCH"
10+
image_name="$DOCKER_REPO:$php_version-$php_variant-$SOURCE_BRANCH"
1111
echo Pushing tag: "$image_name"
1212
docker push "$image_name"
1313
done
File renamed without changes.

0 commit comments

Comments
 (0)