Skip to content

Commit 1d577c6

Browse files
committed
Improved main container layout
Fixes #36 and Fixes #38
1 parent 02244da commit 1d577c6

File tree

7 files changed

+106
-87
lines changed

7 files changed

+106
-87
lines changed

docker/main/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
FROM ubuntu:14.04
22

3+
# Ensure UTF-8
4+
RUN locale-gen en_US.UTF-8
5+
ENV LANG en_US.UTF-8
6+
ENV LC_ALL en_US.UTF-8
7+
38
COPY conf/php.ini /etc/php5/mods-available/docker-boilerplate.ini
49
COPY conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
510
COPY conf/locale.conf /opt/docker/locale.conf

docker/main/bin/dnsmasq.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function dnsmasq_start() {
4040
## set dnsmasq to main nameserver
4141
echo "nameserver 127.0.0.1" > /etc/resolv.conf
4242

43-
## wait for 6 hours
44-
sleep 21600
43+
## wait for 10 hours
44+
sleep 36000
4545
}
4646

4747
## Fetch IP from services

docker/main/bin/init-mysql.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
#############################
4+
## Init MySQL
5+
#############################
6+
7+
echo "[client]
8+
host=mysql
9+
user=\"$MYSQL_USER\"
10+
password=\"$MYSQL_PASSWORD\"
11+
12+
[mysql]
13+
host=mysql
14+
user=\"$MYSQL_USER\"
15+
password=\"$MYSQL_PASSWORD\"
16+
database=\"$MYSQL_DATABASE\"
17+
default-character-set=utf8
18+
local-infile=1
19+
show-warnings
20+
auto-rehash
21+
sigint-ignore
22+
reconnect
23+
24+
[mysqldump]
25+
host=mysql
26+
user=\"$MYSQL_USER\"
27+
password=\"$MYSQL_PASSWORD\"
28+
29+
" | tee /root/.my.cnf > /home/.my.cnf

docker/main/bin/init-php.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
#############################
4+
## Init PHP
5+
#############################
6+
echo "
7+
date.timezone = ${PHP_TIMEZONE}
8+
" >> /etc/php5/mods-available/docker-boilerplate.ini
9+
10+
#############################
11+
## Init PHP-FPM
12+
#############################
13+
14+
# Backup original
15+
if [ ! -f "/opt/docker/.fpm-www.conf" ]; then
16+
cp /etc/php5/fpm/pool.d/www.conf /opt/docker/.fpm-www.conf
17+
fi
18+
19+
## Remove old logs
20+
rm -f -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
21+
touch -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
22+
chmod 666 /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
23+
24+
# Restore original
25+
cp /opt/docker/.fpm-www.conf /etc/php5/fpm/pool.d/www.conf
26+
sed -i "s@listen = /var/run/php5-fpm.sock@listen = 9000@" /etc/php5/fpm/pool.d/www.conf
27+
28+
# Manipulate php-fpm configuration
29+
echo "
30+
; Server resource settings
31+
32+
pm.max_children = 10
33+
pm.start_servers = 2
34+
pm.min_spare_servers = 1
35+
pm.max_spare_servers = 3
36+
37+
catch_workers_output = yes
38+
39+
access.format = \"%R - %u %t \\\"%m %r%Q%q\\\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d\"
40+
access.log = /tmp/php.access.log
41+
slowlog = /tmp/php.slow.log
42+
request_slowlog_timeout = 30s
43+
44+
php_admin_value[error_log] = /tmp/php.error.log
45+
php_admin_flag[log_errors] = on
46+
47+
env[TYPO3_CONTEXT] = ${TYPO3_CONTEXT}
48+
env[FLOW_CONTEXT] = ${FLOW_CONTEXT}
49+
env[FLOW_REWRITEURLS] = ${FLOW_REWRITEURLS}
50+
" >> /etc/php5/fpm/pool.d/www.conf

docker/main/bin/init-ssmtp.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
#############################
4+
## Init SSMTP
5+
#############################
6+
7+
sed -i "s/mailhub=.*/mailhub=${MAIL_GATEWAY}/" /etc/ssmtp/ssmtp.conf
8+
sed -i "s/#FromLineOverride=.*/FromLineOverride=YES/" /etc/ssmtp/ssmtp.conf

docker/main/bin/init-system.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
## Set uid/gid for www-data user
4+
usermod --uid "${PHP_UID}" --shell /bin/bash --home /home www-data
5+
groupmod --gid "${PHP_GID}" www-data

docker/main/entrypoint.sh

Lines changed: 7 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,17 @@
11
#!/bin/bash
22
set -e
33

4-
#############################
5-
## Init UID/GID
6-
#############################
7-
8-
usermod --uid "${PHP_UID}" --shell /bin/bash --home /home www-data
9-
groupmod --gid "${PHP_GID}" www-data
10-
11-
#############################
12-
## Init MySQL
13-
#############################
14-
15-
echo "[client]
16-
host=mysql
17-
user=\"$MYSQL_USER\"
18-
password=\"$MYSQL_PASSWORD\"
4+
## Init system
5+
source /opt/docker/init-system.sh
196

20-
[mysql]
21-
host=mysql
22-
user=\"$MYSQL_USER\"
23-
password=\"$MYSQL_PASSWORD\"
24-
database=\"$MYSQL_DATABASE\"
25-
default-character-set=utf8
26-
local-infile=1
27-
show-warnings
28-
auto-rehash
29-
sigint-ignore
30-
reconnect
7+
## Init MySQL (client)
8+
source /opt/docker/init-mysql.sh
319

32-
[mysqldump]
33-
host=mysql
34-
user=\"$MYSQL_USER\"
35-
password=\"$MYSQL_PASSWORD\"
36-
37-
" | tee /root/.my.cnf > /home/.my.cnf
38-
39-
#############################
4010
## Init SSMTP
41-
#############################
11+
source /opt/docker/init-ssmtp.sh
4212

43-
sed -i "s/mailhub=.*/mailhub=${MAIL_GATEWAY}/" /etc/ssmtp/ssmtp.conf
44-
45-
#############################
46-
## Init PHP
47-
#############################
48-
echo "
49-
date.timezone = ${PHP_TIMEZONE}
50-
" > /etc/php5/mods-available/docker-boilerplate.ini
51-
52-
#############################
53-
## Init PHP-FPM
54-
#############################
55-
56-
# Backup original
57-
if [ ! -f "/opt/docker/.fpm-www.conf" ]; then
58-
cp /etc/php5/fpm/pool.d/www.conf /opt/docker/.fpm-www.conf
59-
fi
60-
61-
## Remove old logs
62-
rm -f -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
63-
touch -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
64-
chmod 666 /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
65-
66-
# Restore original
67-
cp /opt/docker/.fpm-www.conf /etc/php5/fpm/pool.d/www.conf
68-
sed -i "s@listen = /var/run/php5-fpm.sock@listen = 9000@" /etc/php5/fpm/pool.d/www.conf
69-
70-
# Manipulate php-fpm configuration
71-
echo "
72-
; Server resource settings
73-
74-
pm.max_children = 10
75-
pm.start_servers = 2
76-
pm.min_spare_servers = 1
77-
pm.max_spare_servers = 3
78-
79-
catch_workers_output = yes
80-
81-
access.format = \"%R - %u %t \\\"%m %r%Q%q\\\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d\"
82-
access.log = /tmp/php.access.log
83-
slowlog = /tmp/php.slow.log
84-
request_slowlog_timeout = 30s
85-
86-
php_admin_value[error_log] = /tmp/php.error.log
87-
php_admin_flag[log_errors] = on
88-
89-
env[TYPO3_CONTEXT] = ${TYPO3_CONTEXT}
90-
env[FLOW_CONTEXT] = ${FLOW_CONTEXT}
91-
env[FLOW_REWRITEURLS] = ${FLOW_REWRITEURLS}
92-
" >> /etc/php5/fpm/pool.d/www.conf
13+
## Init SSMTP
14+
source /opt/docker/init-php.sh
9315

9416
#############################
9517
## COMMAND

0 commit comments

Comments
 (0)