Skip to content

Commit c412cef

Browse files
committed
Rename docker dir to conf, closes #85
1 parent 1af3448 commit c412cef

File tree

7 files changed

+236
-5
lines changed

7 files changed

+236
-5
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ RUN DEBIAN_FRONTEND=noninteractive \
1818
apt-get clean && apt-get autoremove -q && \
1919
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/*
2020

21-
COPY docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf
22-
COPY docker/supervisord.conf /etc/supervisor/supervisord.conf
21+
COPY conf/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf
22+
COPY conf/supervisord.conf /etc/supervisor/supervisord.conf
2323

2424
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf
2525
RUN mkdir -p /var/www/html && \
2626
chown -R www-data /var/www
2727

28-
COPY docker/crontab /etc/cron.d/artisan-schedule
29-
COPY docker/entrypoint.sh /sbin/entrypoint.sh
28+
COPY conf/crontab /etc/cron.d/artisan-schedule
29+
COPY conf/entrypoint.sh /sbin/entrypoint.sh
3030

3131
RUN chmod 0644 /etc/cron.d/artisan-schedule && \
3232
touch /var/log/cron.log
@@ -46,7 +46,7 @@ RUN wget https://github.com/cachethq/Cachet/archive/${cachet_ver}.tar.gz && \
4646
rm -r ${cachet_ver}.tar.gz && \
4747
php composer.phar install --no-dev -o
4848

49-
COPY docker/.env.docker /var/www/html/.env
49+
COPY conf/.env.docker /var/www/html/.env
5050

5151
VOLUME /var/www
5252
EXPOSE 8000

conf/.env.docker

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
APP_ENV="{{APP_ENV}}"
2+
APP_DEBUG="{{APP_DEBUG}}"
3+
APP_URL="{{APP_URL}}"
4+
APP_KEY={{APP_KEY}}
5+
6+
DB_DRIVER="{{DB_DRIVER}}"
7+
DB_HOST="{{DB_HOST}}"
8+
DB_DATABASE="{{DB_DATABASE}}"
9+
DB_USERNAME="{{DB_USERNAME}}"
10+
DB_PASSWORD="{{DB_PASSWORD}}"
11+
12+
CACHE_DRIVER="{{CACHE_DRIVER}}"
13+
SESSION_DRIVER="{{SESSION_DRIVER}}"
14+
QUEUE_DRIVER="{{QUEUE_DRIVER}}"
15+
16+
MAIL_DRIVER="{{MAIL_DRIVER}}"
17+
MAIL_HOST="{{MAIL_HOST}}"
18+
MAIL_PORT="{{MAIL_PORT}}"
19+
MAIL_USERNAME="{{MAIL_USERNAME}}"
20+
MAIL_PASSWORD="{{MAIL_PASSWORD}}"
21+
MAIL_ADDRESS="{{MAIL_ADDRESS}}"
22+
MAIL_NAME="{{MAIL_NAME}}"
23+
24+
REDIS_HOST="{{REDIS_HOST}}"
25+
REDIS_DATABASE="{{REDIS_DATABASE}}"
26+
REDIS_PORT="{{REDIS_PORT}}"

conf/crontab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#minute hour mday month wday who command
2+
* * * * * www-data php /var/www/html/artisan schedule:run >> /dev/null 2>&1

conf/entrypoint.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
[[ $DEBUG == true ]] && set -x
5+
6+
check_database_connection() {
7+
case ${DB_DRIVER} in
8+
mysql)
9+
prog="mysqladmin -h ${DB_HOST} -u ${DB_USERNAME} ${DB_PASSWORD:+-p$DB_PASSWORD} status"
10+
;;
11+
pgsql)
12+
prog=$(find /usr/lib/postgresql/ -name pg_isready)
13+
prog="${prog} -h ${DB_HOST} -U ${DB_USERNAME} -d ${DB_DATABASE} -t 1"
14+
;;
15+
esac
16+
timeout=60
17+
while ! ${prog} >/dev/null 2>&1
18+
do
19+
timeout=$(( $timeout - 1 ))
20+
if [[ $timeout -eq 0 ]]; then
21+
echo
22+
echo "Could not connect to database server. Aborting..."
23+
return 1
24+
fi
25+
echo -n "."
26+
sleep 1
27+
done
28+
echo
29+
}
30+
31+
initialize_system() {
32+
APP_ENV=${APP_ENV:-development}
33+
APP_DEBUG=${APP_DEBUG:-true}
34+
APP_URL=${APP_URL:-http://localhost}
35+
APP_KEY=${APP_KEY:-SECRET}
36+
37+
DB_DRIVER=${DB_DRIVER:-pgsql}
38+
DB_HOST=${DB_HOST:-postgres}
39+
DB_DATABASE=${DB_DATABASE:-cachet}
40+
DB_USERNAME=${DB_USERNAME:-postgres}
41+
DB_PASSWORD=${DB_PASSWORD:-postgres}
42+
DB_PORT=${DB_PORT:-5432}
43+
44+
CACHE_DRIVER=${CACHE_DRIVER:-apc}
45+
SESSION_DRIVER=${SESSION_DRIVER:-apc}
46+
QUEUE_DRIVER=${QUEUE_DRIVER:-database}
47+
48+
MAIL_DRIVER=${MAIL_DRIVER:-smtp}
49+
MAIL_HOST=${MAIL_HOST:-mailtrap.io}
50+
MAIL_PORT=${MAIL_PORT:-2525}
51+
MAIL_USERNAME=${MAIL_USERNAME:-null}
52+
MAIL_PASSWORD=${MAIL_PASSWORD:-null}
53+
MAIL_ADDRESS=${MAIL_ADDRESS:-null}
54+
MAIL_NAME=${MAIL_NAME:-null}
55+
56+
REDIS_HOST=${REDIS_HOST:-null}
57+
REDIS_DATABASE=${REDIS_DATABASE:-null}
58+
REDIS_PORT=${REDIS_PORT:-null}
59+
60+
# configure env file
61+
62+
sed 's,{{APP_ENV}},'"${APP_ENV}"',g' -i /var/www/html/.env
63+
sed 's,{{APP_DEBUG}},'"${APP_DEBUG}"',g' -i /var/www/html/.env
64+
sed 's,{{APP_URL}},'"${APP_URL}"',g' -i /var/www/html/.env
65+
sed 's,{{APP_KEY}},'${APP_KEY}',g' -i /var/www/html/.env
66+
67+
sed 's,{{DB_DRIVER}},'"${DB_DRIVER}"',g' -i /var/www/html/.env
68+
sed 's,{{DB_HOST}},'"${DB_HOST}"',g' -i /var/www/html/.env
69+
sed 's,{{DB_DATABASE}},'"${DB_DATABASE}"',g' -i /var/www/html/.env
70+
sed 's,{{DB_USERNAME}},'"${DB_USERNAME}"',g' -i /var/www/html/.env
71+
sed 's,{{DB_PASSWORD}},'"${DB_PASSWORD}"',g' -i /var/www/html/.env
72+
73+
sed 's,{{CACHE_DRIVER}},'"${CACHE_DRIVER}"',g' -i /var/www/html/.env
74+
sed 's,{{SESSION_DRIVER}},'"${SESSION_DRIVER}"',g' -i /var/www/html/.env
75+
sed 's,{{QUEUE_DRIVER}},'"${QUEUE_DRIVER}"',g' -i /var/www/html/.env
76+
77+
sed 's,{{MAIL_DRIVER}},'"${MAIL_DRIVER}"',g' -i /var/www/html/.env
78+
sed 's,{{MAIL_HOST}},'"${MAIL_HOST}"',g' -i /var/www/html/.env
79+
sed 's,{{MAIL_PORT}},'"${MAIL_PORT}"',g' -i /var/www/html/.env
80+
sed 's,{{MAIL_USERNAME}},'"${MAIL_USERNAME}"',g' -i /var/www/html/.env
81+
sed 's,{{MAIL_PASSWORD}},'"${MAIL_PASSWORD}"',g' -i /var/www/html/.env
82+
sed 's,{{MAIL_ADDRESS}},'"${MAIL_ADDRESS}"',g' -i /var/www/html/.env
83+
sed 's,{{MAIL_NAME}},'"${MAIL_NAME}"',g' -i /var/www/html/.env
84+
85+
sed 's,{{REDIS_HOST}},'"${REDIS_HOST}"',g' -i /var/www/html/.env
86+
sed 's,{{REDIS_DATABASE}},'"${REDIS_DATABASE}"',g' -i /var/www/html/.env
87+
sed 's,{{REDIS_PORT}},'"${REDIS_PORT}"',g' -i /var/www/html/.env
88+
89+
php composer.phar install --no-dev -o
90+
php artisan app:install
91+
rm -rf bootstrap/cache/*
92+
touch /var/www/.cachet-installed
93+
start_system
94+
}
95+
96+
start_system() {
97+
check_database_connection
98+
[ -f "/var/www/.cachet-installed" ] && echo "Starting Cachet" || initialize_system
99+
php artisan config:cache
100+
sudo /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
101+
}
102+
103+
case ${1} in
104+
init|start)
105+
106+
case ${1} in
107+
start)
108+
start_system
109+
;;
110+
init)
111+
initialize_system
112+
;;
113+
esac
114+
;;
115+
help)
116+
echo "Available options:"
117+
echo " start - Starts the Cachet server (default)"
118+
echo " init - Initialize the Cachet server (e.g. create databases, compile assets)."
119+
echo " help - Displays the help"
120+
echo " [command] - Execute the specified command, eg. bash."
121+
;;
122+
*)
123+
exec "$@"
124+
;;
125+
esac
126+
127+
exit 0

conf/nginx-site.conf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
server {
2+
listen 8000 default; ## Listen for ipv4; this line is default and implied
3+
4+
# Make site accessible from http://localhost/
5+
server_name localhost;
6+
root /var/www/html/public;
7+
8+
index index.html index.htm index.php;
9+
10+
charset utf-8;
11+
12+
location / {
13+
try_files $uri $uri/ /index.php?$query_string;
14+
}
15+
16+
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
17+
location ~ \.php$ {
18+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
19+
include fastcgi_params;
20+
fastcgi_pass cachet:9000;
21+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
22+
fastcgi_index index.php;
23+
fastcgi_keep_conn on;
24+
}
25+
26+
location ~ /\.ht {
27+
deny all;
28+
}
29+
30+
}

conf/php-fpm-pool.conf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[www]
2+
user = www-data
3+
group = www-data
4+
5+
listen = 9000
6+
7+
request_terminate_timeout = 120s
8+
9+
pm = ondemand
10+
pm.max_children = 5
11+
pm.process_idle_timeout = 10s
12+
pm.max_requests = 500
13+
chdir = /
14+
15+
env[DB_DRIVER] = $DB_DRIVER
16+
env[DB_HOST] = $DB_HOST
17+
env[DB_DATABASE] = $DB_DATABASE
18+
env[DB_USERNAME] = $DB_USERNAME
19+
env[DB_PASSWORD] = $DB_PASSWORD
20+
env[CACHE_DRIVER] = $CACHE_DRIVER
21+
22+
23+
[global]
24+
daemonize = no

conf/supervisord.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[supervisord]
2+
logfile=/dev/null ; (main log file;default $CWD/supervisord.log)
3+
logfile_maxbytes=0 ; (max main logfile bytes b4 rotation;default 50MB)
4+
logfile_backups=0 ; (num of main logfile rotation backups;default 10)
5+
loglevel=info ; (log level;default info; others: debug,warn,trace)
6+
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
7+
nodaemon=true ; (start in foreground if true;default false)
8+
9+
; the below section must remain in the config file for RPC
10+
; (supervisorctl/web interface) to work, additional interfaces may be
11+
; added by defining them in separate rpcinterface: sections
12+
[rpcinterface:supervisor]
13+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
14+
15+
[supervisorctl]
16+
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
17+
18+
[program:php-fpm]
19+
command=/usr/sbin/php5-fpm -c /etc/php5/fpm
20+
21+
[program:cron]
22+
command=/usr/sbin/cron -f

0 commit comments

Comments
 (0)