Skip to content

Commit 9d60ec0

Browse files
committed
Updated documentation
1 parent 9dd3c23 commit 9d60ec0

File tree

1 file changed

+186
-51
lines changed

1 file changed

+186
-51
lines changed

README.md

Lines changed: 186 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# PHP Development Docker Images
22

3-
Super simple Docker images for PHP development.
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]
4+
5+
> Super simple Docker images for PHP development.
46
57
**PHP Versions: ** `5.5`, `5.6`, `7.0`, `7.1`, `7.2`
68

79
**PHP Variants:** `cli`
810

11+
**Images based on the** [Official PHP Images][docker-php]
12+
913
**Also installed:**
1014

11-
- Composer
15+
- [Composer][composer]
1216
- PHP modules `XDebug`, `PDO MySQL`
1317

14-
15-
16-
## Pull the Image
18+
## Installation
1719

1820
**Pull the latest version:**
1921

@@ -27,83 +29,216 @@ $ docker pull jestefane/php-dev
2729
$ docker pull jestefane/php-dev:7.2-cli-1.1.0
2830
```
2931

30-
> The image name target has the following format:
32+
Pick between the various [images provided in this repository][images].
33+
34+
**(Optionally) Install the Shortcuts:**
35+
36+
To use the Docker images more like binaries, we're providing [Shortcuts][shortcuts] that can easily be [installed on your system][install-the-shortcuts].
37+
38+
## Images
39+
40+
> Image names have the following format:
3141
>
32-
> `<docker repo>:<php version>-<php variant>-<github repo version>`
42+
> ```
43+
> <docker repo>:<php version>-<php variant>-<github repo version>
44+
> ```
45+
46+
### CLI
3347
34-
## Usage
48+
**Images names**:
3549
36-
### PHP-CLI
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`
55+
56+
**Shortcuts**: [`php-cli`][php-cli-ref], [`composer`][composer-ref]
57+
58+
**Example**:
3759
3860
```bash
39-
docker run --rm -it
40-
-w=/app \
41-
-v /path/to/project:/app \
42-
jestefane/php-dev:7.2-cli-110.0
61+
$ docker run jestefane/php-dev:7.2-cli-1.1.0 hello-world.php
62+
63+
# or using one of the provided shortcuts
64+
$ php-7.2-cli hello-world.php
4365
```
4466
45-
For example:
67+
## Shortcuts
68+
69+
> **Note**: Only tested on some distros of Linux and Mac OS. But hey! It's tested ;)
4670
47-
```shell
48-
docker run --rm -it -w=/app -v $(pwd):/app jestefane/php-dev:7.2-cli-1.1.0 hello-world.php
71+
Shortcuts are simple `bash` scripts wrapping the `docker` command that facilitate command-line-use of the images in this repository.
72+
73+
### Install the Shortcuts
74+
75+
From the root of this directory:
76+
77+
```sh
78+
# If you haven't done so, clone this repository
79+
$ git clone https://github.com/grimzy/php-dev.git
80+
81+
# Get in there!
82+
# Yes, you have to! the script doesn't always work when running from outside
83+
$ cd php-dev
84+
85+
# Generate the scripts and install the shortcuts
86+
make shortcuts
4987
```
5088

51-
### Composer
89+
This generates `bash` scripts in the `scripts` directory (via. [Script Template][templates]). It also adds them to your `PATH` environment variable (Linux and Mac OS only) by creating symlinks of the generated `bash` scripts inside `/usr/local/bin`.
90+
91+
For more info on the `shortcuts` task, please checkout the [Makefile command reference][shortcuts-make].
92+
93+
#### Script Templates
5294

53-
```shell
54-
docker run --rm -it \
55-
-w=/app \
56-
-v /path/to/project:/app \
57-
-v ~/.ssh:/root/.ssh \
58-
-v $HOME/.composer-docker:/root/.composer \
59-
jestefane/php-dev:7.2-cli-1.1.0 composer
95+
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:
96+
97+
```sh
98+
# Removes the scripts directory and generates them back
99+
$ make scripts
60100
```
61101

62-
For example:
102+
For more info on the `scripts` task [Makefile command reference][scripts-make].
103+
104+
### Shortcuts Reference
105+
106+
#### PHP CLI
107+
108+
**Images**: [All respective versions of the PHP CLI variant][cli]
109+
110+
**Shortcuts**: `php-5.5-cli`, `php-5.6-cli`, `php-7.0-cli`, `php-7.1-cli`, `php-7.2-cli`
111+
112+
**Script template**: [template/php-cli.template][php-cli-template]
113+
114+
#### Composer
115+
116+
**Images**: [All respective versions of `jestefane/php-dev` images][images] ([Composer][composer] is installed on every image)
117+
118+
**Shortcuts**: `composer-5.5`, `composer-5.6`, `composer-7.0`, `composer-7.1`, `composer-7.2`
119+
120+
**Script template**: [template/composer.template][composer-template]
121+
122+
## Makefile Commands Reference
63123

64-
```shell
65-
docker run --rm -it \
66-
-w=/app \
67-
-v "$(pwd)":/app \
68-
-v ~/.ssh:/root/.ssh \
69-
-v "$HOME/.composer-docker":/root/.composer \
70-
jestefane/php-dev:7.2-cli-1.1.0 composer install
124+
### Variables
125+
126+
| Variable name | Description | Default value | Possible values |
127+
| --------------- | ------------------------------------------------------------ | ------------------------------------- | ------------------------------------------------------------ |
128+
| `SOURCE_BRANCH` | Appended to the image name | Repository's current version: `1.1.0` | Any `string` value |
129+
| `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` |
131+
| `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` |
132+
| `SCRIPTS_DIR` | Directory where the scripts are generated (or removed). Relative to the repository's root | `scripts` | Any path on your system |
133+
134+
> **Note**: When overriding space separated values from the CLI, you have to escape spaces. For example in `bash` you use `\`:
135+
>
136+
> ```sh
137+
> $ make build PHP_VERSIONS=7.0\ 7.1\ 7.2
138+
> ```
139+
140+
### Tasks
141+
142+
#### Build the Images
143+
144+
Locally builds all images from all possible combinations of `PHP_VERSIONS` and `PHP_VARIANTS`. `SOURCE_BRANCH` is appended to the image name.
145+
146+
**Command:**
147+
148+
```sh
149+
$ make build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=]
150+
```
151+
152+
#### Remove the Images
153+
154+
Remove all locally cached images from all possible combinations of `PHP_VERSIONS` and `PHP_VARIANTS`.
155+
156+
**Command:**
157+
158+
```sh
159+
$ make rm_build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=]
71160
```
72161

73-
## Scripts
162+
#### Rebuild the Images
163+
164+
Alias for removing then building the images: `make rm_build build`.
74165

75-
So you don't have to type the full docker run commands, you can generate shell scripts that alias th
166+
#### Generate the Scripts
76167

77-
```shell
78-
make install_scripts # adds symlinks in /usr/local/bin
168+
Generate the `bash` scripts from [templates][templates] in the `template` directory. Generated scripts are saved in the `SCRIPTS_DIR` directory. The `PHP_VERSION` `PHP_VARIANT` and `SOURCE_BRANCH` are passed to the [templates][templates].
169+
170+
**Command:**
171+
172+
This task first runs: `rm_scripts_dir`
173+
174+
```sh
175+
$ make scripts [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [SCRIPTS_DIR=]
79176
```
80177

81-
> The default is to create symlinks of the scripts inside `/usr/local/bin`. If you'd like to override that, run `make install_scripts BIN_DIR=/dir/of/your/choice`
178+
#### Remove the Generated Scripts Directory
82179

83-
## Building Images Locally
180+
Removes the `SCRIPTS_DIR` directory.
84181

85-
```shell
86-
$ make build
182+
**Command:**
183+
184+
```sh
185+
$ make rm_scripts_dir [SCRIPTS_DIR=]
87186
```
88187

188+
#### Create the Shortcuts
89189

190+
> **Note**: Linux and Mac OS only
90191
91-
## Rebuilding Scripts from Templates
192+
This task creates symlinks of the scripts inside of `SCRIPTS_DIR` inside of the `BIN_DIR`. This adds them to your `PATH` environment variable (Linux and Mac OS only) easily making them available for use on your command line.
92193

93-
```shell
94-
make scripts
194+
**Command:**
195+
196+
```sh
197+
$ make shortcuts [SCRIPTS_DIR=] [BIN_DIR=]
95198
```
96199

97-
## Adding a new PHP version
200+
**Before run:** `make scripts`
98201

99-
In Makefile, add the new version to `VERSIONS`. Then run
202+
#### Remove the Shortcuts
100203

101-
```shell
102-
make builds
204+
This task removes this repository's scripts' symlinks from the `BIN_DIR`.
205+
206+
**Command:**
207+
208+
```sh
209+
$ make rm_shortcuts [PHP_VERSIONS=] [PHP_VARIANTS=] [BIN_DIR=]
103210
```
104211

105-
or run:
212+
#### Remove Dangling Volumes and Images
213+
214+
> **Warning**: Running this task will remove **any** dangling volume and image on your system; not just the ones provided.
215+
216+
**Command:**
217+
218+
```sh
219+
$ make rm_dangling
220+
```
106221

107-
```shell
108-
make builds VERSIONS=7.2
109-
```
222+
## License
223+
224+
[MIT](https://github.com/grimzy/lass/blob/master/LICENSE) © Joseph Estefane
225+
226+
[docker-cloud-automated]: https://img.shields.io/docker/cloud/automated/jestefane/php-dev "Docker Cloud Automated build"
227+
[docker-cloud-build]: https://img.shields.io/docker/cloud/build/jestefane/php-dev "Docker Cloud Build Status"
228+
[docker-pulls]: https://img.shields.io/docker/pulls/jestefane/php-dev "Docker Pulls"
229+
[docker-stars]: https://img.shields.io/docker/stars/jestefane/php-dev "Docker Stars"
230+
[microbadger-layers]: https://img.shields.io/microbadger/layers/jestefane/php-dev/7.2-cli-args-in-build "MicroBadger Layers"
231+
[microbadger-image-size]: https://img.shields.io/microbadger/image-size/jestefane/php-dev/7.2-cli-1.1.0 "MicroBadger Size"
232+
[shortcuts]: #shortcuts "Shortcuts"
233+
[install-the-shortcuts]: #install-the-shortcuts "Install the Shortcuts"
234+
[docker-php]: https://hub.docker.com/_/php "Official Docker PHP Images"
235+
[images]: #images "PHP Images"
236+
[cli]: #cli "PHP CLI Image"
237+
[php-cli-ref]: #php-cli "PHP CLI Scripts"
238+
[php-cli-template]: template/php-cli.template "PHP CLI Template"
239+
[composer]: https://getcomposer.org/ "Composer"
240+
[composer-template]: template/composer.template "Composer Template"
241+
[composer-ref]: #composer ""PHP Composer Scripts""
242+
[templates]: #script-templates "Script Templates"
243+
[shortcuts-make]: #create-the-shortcuts "Create the Shortcuts"
244+
[scripts-make]: #generate-the-scripts "Generate the Scripts"

0 commit comments

Comments
 (0)