Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 7d2c9e1

Browse files
committed
Merge pull request #81 from jdeathe/master
Release changes ready for centos-6-1.4.5
2 parents d94226b + 3a5a4e2 commit 7d2c9e1

File tree

14 files changed

+39
-3270
lines changed

14 files changed

+39
-3270
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# CentOS-6, Apache 2.2, PHP 5.3, PHP Memcached 1.0, PHP APC 3.1.
55
#
66
# =============================================================================
7-
FROM jdeathe/centos-ssh-apache-php:centos-6-1.4.4
7+
FROM jdeathe/centos-ssh-apache-php:centos-6-1.4.5
88

99
MAINTAINER James Deathe <james.deathe@gmail.com>
1010

README.md

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ Run up a container named ```apache-php.app-1.1.1``` from the docker image ```jde
3535
$ docker run -d \
3636
--name apache-php.app-1.1.1 \
3737
-p 8080:80 \
38-
--env "SERVICE_UNIT_APP_GROUP=app-1" \
39-
--env "SERVICE_UNIT_LOCAL_ID=1" \
40-
--env "SERVICE_UNIT_INSTANCE=1" \
4138
--env "APACHE_SERVER_NAME=app-1.local" \
42-
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
4339
-v /var/www \
4440
jdeathe/centos-ssh-apache-php-fcgi:latest
4541
```
@@ -71,7 +67,7 @@ $ docker inspect \
7167
apache-php.app-1.1.1
7268
```
7369

74-
On first run, the bootstrap script, ([/etc/apache-bootstrap](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/apache-bootstrap)), will check if the DocumentRoot directory is empty and, if so, will populate it with the example app scripts and VirtualHost configuration files. If you place your own app in this directory it will not be overwritten but you must ensure to include at least a vhost.conf file and, if enabling SSL a vhost-ssl.conf file too.
70+
On first run, the bootstrap script, ([/etc/apache-bootstrap](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/apache-bootstrap)), will check if the DocumentRoot directory is empty and, if so, will populate it with the example app scripts and VirtualHost configuration files. If you place your own app in this directory it will not be overwritten but you must ensure to include at least a vhost.conf file and, if enabling SSL a vhost-ssl.conf file too.
7571

7672
The ```apachectl``` command can be accessed as follows.
7773

@@ -142,15 +138,7 @@ $ docker run \
142138
```
143139

144140
##### Populating Named configuration data volumes
145-
When using named volumes the directory path from the docker host mounts the path on the container so we need to upload the configuration files. The simplest method of achieving this is to upload the contents of the [etc/services-config](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/) directory using ```docker cp```.
146-
147-
```
148-
$ docker cp \
149-
./etc/services-config/. \
150-
volume-config.apache-php.app-1.1.1:/etc/services-config
151-
```
152-
153-
If you don't have a copy of the required configuration files locally you can run a temporary container as the source of the configuration files and use `docker cp` to stream the files into the named data volume container.
141+
When using named volumes the directory path from the docker host mounts the path on the container so we need to upload the configuration files. The simplest method of achieving this is to run a temporary container as the source of the configuration files and use `docker cp` to stream the files into the named data volume container.
154142

155143
```
156144
$ docker run -d \
@@ -179,10 +167,10 @@ $ docker run --rm -it \
179167

180168
The following configuration files are required to run the application container and should be located in the directory /etc/services-config/.
181169

182-
- [httpd/conf/httpd.conf](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/httpd/conf/httpd.conf)
183-
- [httpd/conf.d/php.conf](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/httpd/conf.d/php.conf)
184-
- [httpd/conf.d/ssl.conf](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/httpd/conf.d/ssl.conf)
185-
- [supervisor/supervisord.conf](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/supervisor/supervisord.conf)
170+
- [httpd/conf/httpd.conf](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/services-config/httpd/conf/httpd.conf)
171+
- [httpd/conf.d/fcgid.conf](https://github.com/jdeathe/centos-ssh-apache-php-fgci/blob/centos-6/etc/services-config/httpd/conf.d/fcgid.conf)
172+
- [httpd/conf.d/ssl.conf](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/services-config/httpd/conf.d/ssl.conf)
173+
- [supervisor/supervisord.conf](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/services-config/supervisor/supervisord.conf)
186174

187175
### Running
188176

@@ -198,9 +186,6 @@ $ docker stop apache-php.app-1.1.1 && \
198186
$ docker run -d \
199187
--name apache-php.app-1.1.1 \
200188
-p 8080:80 \
201-
--env "SERVICE_UNIT_INSTANCE=app-1" \
202-
--env "SERVICE_UNIT_LOCAL_ID=1" \
203-
--env "SERVICE_UNIT_INSTANCE=1" \
204189
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
205190
--env "APACHE_CUSTOM_LOG_FORMAT=combined" \
206191
--env "APACHE_CUSTOM_LOG_LOCATION=/var/www/app-1/var/log/apache_access_log" \
@@ -215,6 +200,7 @@ $ docker run -d \
215200
--env "APACHE_SERVER_NAME=app-1.local" \
216201
--env "APACHE_SYSTEM_USER=app" \
217202
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
203+
--env "SERVICE_UID=app-1.1.1" \
218204
-v volume-data.apache-php.app-1.1.1:/var/www \
219205
jdeathe/centos-ssh-apache-php-fcgi:latest
220206
```
@@ -229,12 +215,10 @@ $ docker stop apache-php.app-1.1.1 && \
229215
$ docker run -d \
230216
--name apache-php.app-1.1.1 \
231217
-p 8080:80 \
232-
--env "SERVICE_UNIT_INSTANCE=app-1" \
233-
--env "SERVICE_UNIT_LOCAL_ID=1" \
234-
--env "SERVICE_UNIT_INSTANCE=1" \
235218
--env "APACHE_SERVER_ALIAS=app-1" \
236219
--env "APACHE_SERVER_NAME=app-1.local" \
237220
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
221+
--env "SERVICE_UID=app-1.1.1" \
238222
--volumes-from volume-config.apache-php.app-1.1.1 \
239223
-v volume-data.apache-php.app-1.1.1:/var/www \
240224
jdeathe/centos-ssh-apache-php-fcgi:latest
@@ -248,30 +232,26 @@ $ docker logs apache-php.app-1.1.1
248232

249233
The output of the logs should show the Apache modules being loaded and auto-generated password for the Apache user and group, (if not try again after a few seconds).
250234

251-
#### Runtime Environment Variables
252-
253-
There are several environmental variables defined at runtime these allow the operator to customise the running container which may become necessary when running several on the same docker host, when clustering docker hosts or to simply set the timezone.
235+
#### Environment Variables
254236

255-
##### SERVICE_UNIT_INSTANCE, SERVICE_UNIT_LOCAL_ID & SERVICE_UNIT_INSTANCE
237+
##### APACHE_SERVER_NAME & APACHE_SERVER_ALIAS
256238

257-
The ```SERVICE_UNIT_INSTANCE```, ```SERVICE_UNIT_LOCAL_ID``` and ```SERVICE_UNIT_INSTANCE``` environmental variables are used to set a response header named ```X-Service-Uid``` that lets you identify the container that is serving the content. This is useful when you have many containers running on a single host using different ports (i.e with different ```SERVICE_UNIT_LOCAL_ID``` values) or if you are running a cluster and need to identify which host the content is served from (i.e with different ```SERVICE_UNIT_INSTANCE``` values). The three values should map to the last 3 dotted values of the container name; in our case that is "app-1.1.1"
239+
The ```APACHE_SERVER_NAME``` and ```APACHE_SERVER_ALIAS``` environmental variables are used to set the VirtualHost ```ServerName``` and ```ServerAlias``` values respectively. In the following example the running container would respond to the host names ```app-1.local``` or ```app-1```:
258240

259241
```
260242
...
261-
--env "SERVICE_UNIT_APP_GROUP=app-1" \
262-
--env "SERVICE_UNIT_LOCAL_ID=1" \
263-
--env "SERVICE_UNIT_INSTANCE=1" \
243+
--env "APACHE_SERVER_ALIAS=app-1" \
244+
--env "APACHE_SERVER_NAME=app-1.local" \
264245
...
265246
```
266247

267-
##### APACHE_SERVER_NAME & APACHE_SERVER_ALIAS
248+
##### APACHE_CONTENT_ROOT
268249

269-
The ```APACHE_SERVER_NAME``` and ```APACHE_SERVER_ALIAS``` environmental variables are used to set the VirtualHost ```ServerName``` and ```ServerAlias``` values respectively. In the following example the running container would respond to the host names ```app-1.local``` or ```app-1```:
250+
The home directory of the service user and parent directory of the Apache DocumentRoot is /var/www/app by default but can be changed if necessary using the ```APACHE_CONTENT_ROOT``` environment variable.
270251

271252
```
272253
...
273-
--env "APACHE_SERVER_ALIAS=app-1" \
274-
--env "APACHE_SERVER_NAME=app-1.local" \
254+
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
275255
...
276256
```
277257

@@ -288,7 +268,7 @@ The Apache CustomLog can be defined using ```APACHE_CUSTOM_LOG_LOCATION``` to se
288268
...
289269
```
290270

291-
##### APACHE_ERROR_LOG_LOCATION && APACHE_ERROR_LOG_LEVEL
271+
##### APACHE_ERROR_LOG_LOCATION & APACHE_ERROR_LOG_LEVEL
292272

293273
The Apache ErrorLog can be defined using ```APACHE_ERROR_LOG_LOCATION``` to set a file | pipe location and ```APACHE_ERROR_LOG_LEVEL``` to specify the required LogLevel value.
294274

@@ -314,8 +294,8 @@ You can view the output from Apache server-status either using the elinks browse
314294
```
315295
$ docker exec -it apache-php.app-1.1.1 \
316296
env TERM=xterm \
317-
watch -n 10 \
318-
-d "curl -s http://app-1/_httpdstatus?auto"
297+
watch -n 1 \
298+
-d "curl -s http://app-1/server-status?auto"
319299
```
320300

321301
##### APACHE_LOAD_MODULES
@@ -363,23 +343,23 @@ The Apache process is run by the User and Group defined by ```APACHE_RUN_USER```
363343
...
364344
```
365345

366-
##### APACHE_CONTENT_ROOT
346+
##### APACHE_PUBLIC_DIRECTORY
367347

368-
The home directory of the service user and parent directory of the Apache DocumentRoot is /var/www/app by default but can be changed if necessary using the ```APACHE_CONTENT_ROOT``` environment variable.
348+
The public directory is relative to the ```APACHE_CONTENT_ROOT``` and together they form the Apache DocumentRoot path. The default value is `public_html` and should not be changed unless changes are made to the source of the app to include an alternative public directory such as `web` or `public`.
369349

370350
```
371351
...
372-
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
352+
--env "APACHE_PUBLIC_DIRECTORY=web" \
373353
...
374354
```
375355

376-
##### APACHE_PUBLIC_DIRECTORY
356+
##### APACHE_SYSTEM_USER
377357

378-
The public directory is relative to the ```APACHE_CONTENT_ROOT``` and together they form the Apache DocumentRoot path. The default value is `public_html` and should not be changed unless changes are made to the source of the app to include an alternative public directory such as `web` or `public`.
358+
Use the ```APACHE_SYSTEM_USER``` environment variable to define a custom service username.
379359

380360
```
381361
...
382-
--env "APACHE_PUBLIC_DIRECTORY=web" \
362+
--env "APACHE_SYSTEM_USER=app-1" \
383363
...
384364
```
385365

@@ -395,21 +375,21 @@ To set the timezone for the UK and account for British Summer Time you would use
395375
...
396376
```
397377

398-
##### APACHE_SYSTEM_USER
378+
##### SERVICE_UID
399379

400-
Use the ```APACHE_SYSTEM_USER``` environment variable to define a custom service username.
380+
The ```SERVICE_UID``` environmental variable is used to set a response header named ```X-Service-Uid``` that lets you identify the container that is serving the content. This is useful when you have many containers running on a single host using different ports or if you are running a cluster and need to identify which host the content is served from. The default value is set to the Service Unit's App Group Name, Local ID and Instance ID.
401381

402382
```
403383
...
404-
--env "APACHE_SYSTEM_USER=app-1" \
384+
--env "SERVICE_UID=app-1.1.1" \
405385
...
406386
```
407387

408388
### Custom Configuration
409389

410390
If using the optional data volume for container configuration you are able to customise the configuration. In the following examples your custom docker configuration files should be located on the Docker host under the directory ```/var/lib/docker/volumes/<volume-name>/``` where ```<container-name>``` should match the applicable container name such as "apache-php.app-1.1.1" if using named volumes or will be an ID generated automatically by Docker. To identify the correct path on the Docker host use the ```docker inspect``` command.
411391

412-
#### [httpd/apache-bootstrap.conf](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/httpd/apache-bootstrap.conf)
392+
#### [httpd/apache-bootstrap.conf](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/services-config/httpd/apache-bootstrap.conf)
413393

414394
The bootstrap script initialises the app. It sets up the Apache service user + group, generates passwords, enables Apache modules and adds/removes SSL support.
415395

@@ -433,6 +413,6 @@ To override the SSLCertificateKeyFile add it to your config directory using the
433413

434414
*Note:* You must also specify the associated SSLCertificateFile in this case.
435415

436-
#### [supervisor/supervisord.conf](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/services-config/supervisor/supervisord.conf)
416+
#### [supervisor/supervisord.conf](https://github.com/jdeathe/centos-ssh-apache-php/blob/centos-6/etc/services-config/supervisor/supervisord.conf)
437417

438418
The supervisor service's configuration can also be overridden by editing the custom supervisord.conf file. It shouldn't be necessary to change the existing configuration here but you could include more [program:x] sections to run additional commands at startup.

apache-php.app-1.1.1@8080.service

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RestartSec=30
2929
TimeoutStartSec=1200
3030
Environment="DOCKER_IMAGE_PACKAGE_PATH=/var/services-packages"
3131
Environment="DOCKER_IMAGE_NAME=jdeathe/centos-ssh-apache-php-fcgi"
32-
Environment="DOCKER_IMAGE_TAG=centos-6-1.4.4"
32+
Environment="DOCKER_IMAGE_TAG=centos-6-1.4.5"
3333
Environment="SERVICE_UNIT_APP_GROUP=app-1"
3434
Environment="SERVICE_UNIT_LOCAL_ID=1"
3535
Environment="SERVICE_UNIT_INSTANCE=1"
@@ -45,6 +45,7 @@ Environment="APACHE_ERROR_LOG_LEVEL=warn"
4545
Environment="APACHE_EXTENDED_STATUS_ENABLED=false"
4646
Environment="APACHE_LOAD_MODULES=authz_user_module log_config_module expires_module deflate_module headers_module setenvif_module mime_module status_module dir_module alias_module"
4747
Environment="APACHE_MOD_SSL_ENABLED=false"
48+
Environment="APACHE_OPERATING_MODE=production"
4849
Environment="APACHE_PUBLIC_DIRECTORY=public_html"
4950
Environment="APACHE_RUN_GROUP=app-www"
5051
Environment="APACHE_RUN_USER=app-www"
@@ -109,12 +110,10 @@ ExecStart=/bin/sudo /bin/bash -c \
109110
--name %p \
110111
-p %i:80 \
111112
-p 8580:8443 \
112-
--env \"SERVICE_UNIT_APP_GROUP=${SERVICE_UNIT_APP_GROUP}\" \
113-
--env \"SERVICE_UNIT_LOCAL_ID=${SERVICE_UNIT_LOCAL_ID}\" \
114-
--env \"SERVICE_UNIT_INSTANCE=${SERVICE_UNIT_INSTANCE}\" \
115113
--env \"APACHE_SERVER_ALIAS=${APACHE_SERVER_ALIAS}\" \
116114
--env \"APACHE_SERVER_NAME=${APACHE_SERVER_NAME}\" \
117115
--env \"PHP_OPTIONS_DATE_TIMEZONE=${PHP_OPTIONS_DATE_TIMEZONE}\" \
116+
--env \"SERVICE_UID=${SERVICE_UNIT_APP_GROUP}.${SERVICE_UNIT_LOCAL_ID}.${SERVICE_UNIT_INSTANCE}\" \
118117
--volumes-from volume-config.%p \
119118
-v ${VOLUME_DATA_NAME}:${APACHE_SERVER_HOME} \
120119
${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}; \
@@ -123,9 +122,6 @@ ExecStart=/bin/sudo /bin/bash -c \
123122
--name %p \
124123
-p %i:80 \
125124
-p 8580:8443 \
126-
--env \"SERVICE_UNIT_APP_GROUP=${SERVICE_UNIT_APP_GROUP}\" \
127-
--env \"SERVICE_UNIT_LOCAL_ID=${SERVICE_UNIT_LOCAL_ID}\" \
128-
--env \"SERVICE_UNIT_INSTANCE=${SERVICE_UNIT_INSTANCE}\" \
129125
--env \"APACHE_CONTENT_ROOT=${APACHE_CONTENT_ROOT}\" \
130126
--env \"APACHE_CUSTOM_LOG_FORMAT=${APACHE_CUSTOM_LOG_FORMAT}\" \
131127
--env \"APACHE_CUSTOM_LOG_LOCATION=${APACHE_CUSTOM_LOG_LOCATION}\" \
@@ -142,6 +138,7 @@ ExecStart=/bin/sudo /bin/bash -c \
142138
--env \"APACHE_SYSTEM_USER=${APACHE_SYSTEM_USER}\" \
143139
--env \"HTTPD=${HTTPD}\" \
144140
--env \"PHP_OPTIONS_DATE_TIMEZONE=${PHP_OPTIONS_DATE_TIMEZONE}\" \
141+
--env \"SERVICE_UID=${SERVICE_UNIT_APP_GROUP}.${SERVICE_UNIT_LOCAL_ID}.${SERVICE_UNIT_INSTANCE}\" \
145142
-v ${VOLUME_DATA_NAME}:${APACHE_SERVER_HOME} \
146143
${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}; \
147144
fi"

0 commit comments

Comments
 (0)