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

Commit a2f0601

Browse files
committed
Merge pull request #71 from jdeathe/master
Release changes ready for centos-6-1.4.3
2 parents 33f8d50 + 1a09dba commit a2f0601

File tree

11 files changed

+728
-315
lines changed

11 files changed

+728
-315
lines changed

Dockerfile

Lines changed: 22 additions & 16 deletions
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.2
7+
FROM jdeathe/centos-ssh-apache-php:centos-6-1.4.3
88

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

@@ -61,26 +61,32 @@ RUN ln -sf /etc/services-config/httpd/apache-bootstrap.conf /etc/apache-bootstra
6161
# -----------------------------------------------------------------------------
6262
# Set default environment variables used to identify the service container
6363
# -----------------------------------------------------------------------------
64-
ENV SERVICE_UNIT_APP_GROUP app-1
65-
ENV SERVICE_UNIT_LOCAL_ID 1
66-
ENV SERVICE_UNIT_INSTANCE 1
64+
# ENV SERVICE_UNIT_APP_GROUP app-1
65+
# ENV SERVICE_UNIT_LOCAL_ID 1
66+
# ENV SERVICE_UNIT_INSTANCE 1
6767

6868
# -----------------------------------------------------------------------------
6969
# Set default environment variables used to configure the service container
7070
# -----------------------------------------------------------------------------
71-
ENV APACHE_EXTENDED_STATUS_ENABLED false
72-
ENV 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"
73-
ENV APACHE_MOD_SSL_ENABLED false
74-
ENV APACHE_SERVER_ALIAS ""
75-
ENV APACHE_SERVER_NAME app-1.local
76-
ENV APP_HOME_DIR /var/www/app
77-
ENV DATE_TIMEZONE UTC
71+
# ENV APACHE_CONTENT_ROOT /var/www/${PACKAGE_NAME}
72+
# ENV APACHE_CUSTOM_LOG_FORMAT combined
73+
# ENV APACHE_CUSTOM_LOG_LOCATION ${APACHE_CONTENT_ROOT}/var/log/apache_access_log
74+
# ENV APACHE_ERROR_LOG_LOCATION ${APACHE_CONTENT_ROOT}/var/log/apache_error_log
75+
# ENV APACHE_ERROR_LOG_LEVEL warn
76+
# ENV APACHE_EXTENDED_STATUS_ENABLED false
77+
# ENV 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"
78+
# ENV APACHE_MOD_SSL_ENABLED false
79+
# ENV APACHE_PUBLIC_DIRECTORY public_html
80+
# ENV APACHE_RUN_GROUP app-www
81+
# ENV APACHE_RUN_USER app-www
82+
# ENV APACHE_SERVER_ALIAS ""
83+
# ENV APACHE_SERVER_NAME app-1.local
84+
# ENV APACHE_SUEXEC_USER_GROUP false
85+
# ENV APACHE_SYSTEM_USER app
7886
ENV HTTPD /usr/sbin/httpd.worker
79-
ENV SERVICE_USER app
80-
ENV SERVICE_USER_GROUP app-www
81-
ENV SERVICE_USER_PASSWORD ""
82-
ENV SUEXECUSERGROUP false
87+
# ENV PACKAGE_PATH ${PACKAGE_PATH}
88+
# ENV PHP_OPTIONS_DATE_TIMEZONE UTC
8389

84-
EXPOSE 80 8443 443
90+
# EXPOSE 80 8443 443
8591

8692
CMD ["/usr/bin/supervisord", "--configuration=/etc/supervisord.conf"]

README.md

Lines changed: 75 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ $ docker run -d \
3939
--env "SERVICE_UNIT_LOCAL_ID=1" \
4040
--env "SERVICE_UNIT_INSTANCE=1" \
4141
--env "APACHE_SERVER_NAME=app-1.local" \
42-
--env "DATE_TIMEZONE=UTC" \
43-
-v /var/www/app \
42+
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
43+
-v /var/www \
4444
jdeathe/centos-ssh-apache-php-fcgi:latest
4545
```
4646

@@ -63,7 +63,7 @@ To verify the container is initialised and running successfully by inspecting th
6363
$ docker logs apache-php.app-1.1.1
6464
```
6565

66-
The Apache data is persistent across container restarts by setting the data directory ```/var/www/app``` as a data volume. No name or docker_host path was specified so Docker will give it a unique name and store it in ```/var/lib/docker/volumes/```; to find out where the data is stored on the Docker host you can use ```docker inspect```.
66+
The Apache data is persistent across container restarts by setting the data directory ```/var/www``` as a data volume. No name or docker_host path was specified so Docker will give it a unique name and store it in ```/var/lib/docker/volumes/```; to find out where the data is stored on the Docker host you can use ```docker inspect```.
6767

6868
```
6969
$ docker inspect \
@@ -201,23 +201,27 @@ $ docker run -d \
201201
--env "SERVICE_UNIT_INSTANCE=app-1" \
202202
--env "SERVICE_UNIT_LOCAL_ID=1" \
203203
--env "SERVICE_UNIT_INSTANCE=1" \
204+
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
205+
--env "APACHE_CUSTOM_LOG_FORMAT=combined" \
206+
--env "APACHE_CUSTOM_LOG_LOCATION=/var/www/app-1/var/log/apache_access_log" \
207+
--env "APACHE_ERROR_LOG_LOCATION=/var/www/app-1/var/log/apache_error_log" \
208+
--env "APACHE_ERROR_LOG_LEVEL=warn" \
204209
--env "APACHE_EXTENDED_STATUS_ENABLED=false" \
205210
--env "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 rewrite_module" \
206211
--env "APACHE_MOD_SSL_ENABLED=false" \
212+
--env "APACHE_RUN_GROUP=www-app" \
213+
--env "APACHE_RUN_USER=www-app" \
207214
--env "APACHE_SERVER_ALIAS=app-1" \
208215
--env "APACHE_SERVER_NAME=app-1.local" \
209-
--env "APP_HOME_DIR=/var/www/app-1" \
210-
--env "DATE_TIMEZONE=UTC" \
211-
--env "SERVICE_USER=app" \
212-
--env "SERVICE_USER_GROUP=app-www" \
213-
--env "SERVICE_USER_PASSWORD=" \
214-
-v volume-data.apache-php.app-1.1.1:/var/www/app-1 \
216+
--env "APACHE_SYSTEM_USER=app" \
217+
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
218+
-v volume-data.apache-php.app-1.1.1:/var/www \
215219
jdeathe/centos-ssh-apache-php-fcgi:latest
216220
```
217221

218222
#### Using configuration volume
219223

220-
The following example uses the settings from the optonal configuration volume volume-config.apache-php.app-1.1.1 and maps a data volume for persistent storage of the Apache app data on the docker host.
224+
The following example uses the settings from the optional configuration volume volume-config.apache-php.app-1.1.1 and maps a data volume for persistent storage of the Apache app data on the docker host.
221225

222226
```
223227
$ docker stop apache-php.app-1.1.1 && \
@@ -230,9 +234,9 @@ $ docker run -d \
230234
--env "SERVICE_UNIT_INSTANCE=1" \
231235
--env "APACHE_SERVER_ALIAS=app-1" \
232236
--env "APACHE_SERVER_NAME=app-1.local" \
233-
--env "DATE_TIMEZONE=UTC" \
237+
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
234238
--volumes-from volume-config.apache-php.app-1.1.1 \
235-
-v volume-data.apache-php.app-1.1.1:/var/www/app \
239+
-v volume-data.apache-php.app-1.1.1:/var/www \
236240
jdeathe/centos-ssh-apache-php-fcgi:latest
237241
```
238242

@@ -248,7 +252,7 @@ The output of the logs should show the Apache modules being loaded and auto-gene
248252

249253
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.
250254

251-
##### 1. SERVICE_UNIT_INSTANCE, SERVICE_UNIT_LOCAL_ID & SERVICE_UNIT_INSTANCE
255+
##### SERVICE_UNIT_INSTANCE, SERVICE_UNIT_LOCAL_ID & SERVICE_UNIT_INSTANCE
252256

253257
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"
254258

@@ -260,7 +264,7 @@ The ```SERVICE_UNIT_INSTANCE```, ```SERVICE_UNIT_LOCAL_ID``` and ```SERVICE_UNIT
260264
...
261265
```
262266

263-
##### 2. APACHE_SERVER_NAME & APACHE_SERVER_ALIAS
267+
##### APACHE_SERVER_NAME & APACHE_SERVER_ALIAS
264268

265269
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```:
266270

@@ -273,7 +277,29 @@ The ```APACHE_SERVER_NAME``` and ```APACHE_SERVER_ALIAS``` environmental variabl
273277

274278
from your browser you can then access it with ```http://app-1.local:8080``` assuming you have the IP address of your docker mapped to the hostname using your DNS server or a local hosts entry.
275279

276-
##### 3. APACHE_EXTENDED_STATUS_ENABLED
280+
##### APACHE_CUSTOM_LOG_LOCATION & APACHE_CUSTOM_LOG_FORMAT
281+
282+
The Apache CustomLog can be defined using ```APACHE_CUSTOM_LOG_LOCATION``` to set a file | pipe location and ```APACHE_CUSTOM_LOG_FORMAT``` to specify the required LogFormat nickname.
283+
284+
```
285+
...
286+
--env "APACHE_CUSTOM_LOG_LOCATION=/var/log/httpd/access_log" \
287+
--env "APACHE_CUSTOM_LOG_FORMAT=common" \
288+
...
289+
```
290+
291+
##### APACHE_ERROR_LOG_LOCATION && APACHE_ERROR_LOG_LEVEL
292+
293+
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.
294+
295+
```
296+
...
297+
--env "APACHE_CUSTOM_LOG_LOCATION=/var/log/httpd/error_log" \
298+
--env "APACHE_CUSTOM_LOG_FORMAT=error" \
299+
...
300+
```
301+
302+
##### APACHE_EXTENDED_STATUS_ENABLED
277303

278304
The variable ```APACHE_EXTENDED_STATUS_ENABLED``` allows you to turn ExtendedStatus on. It is turned off by default as it has an impact on the server's performance but with it enabled you can gather more statistics.
279305

@@ -292,7 +318,7 @@ $ docker exec -it apache-php.app-1.1.1 \
292318
-d "curl -s http://app-1/_httpdstatus?auto"
293319
```
294320

295-
##### 4. APACHE_LOAD_MODULES
321+
##### APACHE_LOAD_MODULES
296322

297323
The variable ```APACHE_LOAD_MODULES``` defines all Apache modules to be loaded from */etc/httpd/conf/http.conf*. The default is the minimum required so you may need to add more as necessary. To add the "mod\_rewrite" Apache Module you would add it's identifier ```rewrite_module``` to the array as follows.
298324

@@ -302,7 +328,7 @@ The variable ```APACHE_LOAD_MODULES``` defines all Apache modules to be loaded f
302328
...
303329
```
304330

305-
##### 5. APACHE_MOD_SSL_ENABLED
331+
##### APACHE_MOD_SSL_ENABLED
306332

307333
By default SSL support is disabled but a second port, (mapped to 8443), is available for traffic that has been been through upstream SSL termination (SSL Offloading). If you want the container to support SSL directly then set ```APACHE_MOD_SSL_ENABLED=true``` this will then generate a self signed certificate and will update Apache to accept traffic on port 443.
308334

@@ -321,43 +347,61 @@ $ docker run -d \
321347
--env "APACHE_SERVER_ALIAS=app-1" \
322348
--env "APACHE_SERVER_NAME=app-1.local" \
323349
--env "APACHE_MOD_SSL_ENABLED=true" \
324-
--env "DATE_TIMEZONE=UTC" \
325-
-v volume-data.apache-php.app-1.1.1:/var/www/app \
350+
--env "PHP_OPTIONS_DATE_TIMEZONE=UTC" \
351+
-v volume-data.apache-php.app-1.1.1:/var/www \
326352
jdeathe/centos-ssh-apache-php-fcgi:latest
327353
```
328354

329-
##### 6. APP_HOME_DIR
355+
##### APACHE_RUN_USER & APACHE_RUN_GROUP
356+
357+
The Apache process is run by the User and Group defined by ```APACHE_RUN_USER``` and ```APACHE_RUN_GROUP``` respectively.
358+
359+
```
360+
...
361+
--env "APACHE_RUN_GROUP=www-app" \
362+
--env "APACHE_RUN_USER=www-app" \
363+
...
364+
```
365+
366+
##### APACHE_CONTENT_ROOT
367+
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.
369+
370+
```
371+
...
372+
--env "APACHE_CONTENT_ROOT=/var/www/app-1" \
373+
...
374+
```
375+
376+
##### APACHE_PUBLIC_DIRECTORY
330377

331-
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 ```APP_HOME_DIR``` environment variable. It is also necessary to change the target of the data volume mapping accordingly as in the following example where /var/www/app-1 is used.
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`.
332379

333380
```
334381
...
335-
--env "APP_HOME_DIR=/var/www/app-1" \
336-
-v volume-data.apache-php.app-1.1.1:/var/www/app-1 \
382+
--env "APACHE_PUBLIC_DIRECTORY=web" \
337383
...
338384
```
339385

340-
##### 7. DATE_TIMEZONE
386+
##### PHP_OPTIONS_DATE_TIMEZONE
341387

342-
The default timezone for the container, and the PHP app, is UTC however the operator can set an appropriate timezone using the ```DATE_TIMEZONE``` variable. The value should be a timezone identifier, like UTC or Europe/London. The list of valid identifiers is available in the PHP [List of Supported Timezones](http://php.net/manual/en/timezones.php).
388+
The default timezone for the container, and the PHP app, is UTC however the operator can set an appropriate timezone using the ```PHP_OPTIONS_DATE_TIMEZONE``` variable. The value should be a timezone identifier, like UTC or Europe/London. The list of valid identifiers is available in the PHP [List of Supported Timezones](http://php.net/manual/en/timezones.php).
343389

344390
To set the timezone for the UK and account for British Summer Time you would use:
345391

346392
```
347393
...
348-
--env "DATE_TIMEZONE=Europe/London" \
394+
--env "PHP_OPTIONS_DATE_TIMEZONE=Europe/London" \
349395
...
350396
```
351397

352-
##### 8. SERVICE_USER, SERVICE_USER_GROUP & SERVICE_USER_PASSWORD
398+
##### APACHE_SYSTEM_USER
353399

354-
Use the ```SERVICE_USER```, ```SERVICE_USER_GROUP``` and ```SERVICE_USER_PASSWORD``` environment variables to define a custom service username, group and password respectively. If the password is left an empty string then it is automatically generated on first run which is the default.
400+
Use the ```APACHE_SYSTEM_USER``` environment variable to define a custom service username.
355401

356402
```
357403
...
358-
--env "SERVICE_USER=apacheUser" \
359-
--env "SERVICE_USER_GROUP=apacheGroup" \
360-
--env "SERVICE_USER_PASSWORD=userPassword123" \
404+
--env "APACHE_SYSTEM_USER=app-1" \
361405
...
362406
```
363407

0 commit comments

Comments
 (0)