Skip to content

Commit 23bc8a8

Browse files
committed
First commit
0 parents  commit 23bc8a8

File tree

6 files changed

+290
-0
lines changed

6 files changed

+290
-0
lines changed

‎Dockerfile‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
FROM phusion/baseimage:latest
3+
MAINTAINER gabriel schubiner <gabriel.schubiner@gmail.com>
4+
5+
# Installation
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
apache2 \
8+
git \
9+
unzip \
10+
memcached \
11+
php5 \
12+
php5-mysqlnd \
13+
php5-pgsql \
14+
php5-imap \
15+
php5-cli \
16+
php-pear \
17+
php-apc \
18+
php5-gd \
19+
php5-memcached \
20+
python-pip
21+
22+
23+
# Networking
24+
#RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \
25+
# && echo "NETWORKING=yes" > /etc/sysconfig/network
26+
27+
# SSH
28+
#RUN rm -f /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_rsa_key \
29+
# && ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_ecdsa_key \
30+
# && ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key
31+
32+
#RUN sed -i \
33+
# -e 's/^#UseDNS yes/UseDNS no/g' \
34+
# -e 's/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g' \
35+
# /etc/ssh/sshd_config
36+
37+
# -e 's/^#UsePAM no/UsePAM no/g' \
38+
# -e 's/^UsePAM yes/#UsePAM yes/g' \
39+
# -e 's/^PasswordAuthentication yes/PasswordAuthentication no/g' \
40+
41+
### Set Root Pass
42+
#ADD ./assets/scripts/set_root_pass.sh /opt/set_root_pass.sh
43+
44+
#RUN chmod +x /opt/set_root_pass.sh
45+
46+
### SUDO
47+
#RUN sed -i 's/^# %wheel\tALL=(ALL)\tALL/%wheel\tALL=(ALL)\tALL/g' /etc/sudoers
48+
49+
# PHP Config
50+
RUN sed -i \
51+
-e 's/^memory_limit.*$/memory_limit = 1024M/g' \
52+
-e 's/^max_execution_time.*$/max_execution_time = 900/g' \
53+
-e 's/^session.save_handler.*$/session.save_handler = memcache/g' \
54+
-e 's/^post_max_size.*$/post_max_size = 512M/g' \
55+
-e 's/^upload_max_file_size.*$/upload_max_file_size = 512M/g' \
56+
-e 's/^max_file_uploads.*$/max_file_uploads = 100/g' \
57+
/etc/php5/apache2/php.ini
58+
59+
RUN pear channel-discover pear.drush.org && \
60+
pear install drush/drush
61+
62+
# Pushtape
63+
64+
RUN rm /var/www/html/* && \
65+
curl http://ftp.drupal.org/files/projects/pushtape-7.x-1.0-beta18.tar.gz | tar xz -C /var/www/html --strip-components=1
66+
67+
RUN cd /var/www/html && \
68+
drush make build-pushtape.make ./ && \
69+
cd /
70+
71+
#RUN chown -R root:apache /var/www/html/*
72+
#RUN chown -R apache:apache /var/www/html/sites/default
73+
#RUN chown -R apache:apache /var/www/html/sites/all
74+
75+
EXPOSE 22 80 443
76+
77+
# Supervisor
78+
#ADD ./assets/supervisor/supervisord.conf /etc/supervisord.conf
79+
#ADD ./assets/crontab /etc/crontab
80+
#ADD ./assets/scripts/entrypoint.sh /entrypoint.sh
81+
82+
#RUN chmod +x /entrypoint.sh
83+
84+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
85+
86+
ENTRYPOINT ["/sbin/my_init"]

‎README.md‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# docker install for Pushtape
2+
3+
This repo contains an initial working repository for Pushtape, a drupal distribution for creating music-oriented websites.
4+
5+
* NOTE: Still in development -- doesn't work yet. below info is planned
6+
7+
## Set-up Notes
8+
9+
For drupal/pushtape install procedure, you must access http://site-name.tld/install.php directly. Drupal won't redirect http://site-name.tld to the install page directly, because settings.php has been modified with database settings.
10+
11+
## OS
12+
13+
Based on Debian.
14+
15+
## DB
16+
17+
MariaDB or MySQL DB setup is automatic through docker linking with appropriate environment variables for the DB container.
18+
19+
## Memcache
20+
21+
I think it's set up correctly, but haven't really checked.
22+
23+
## Cron
24+
25+
Untested cron with crontab installed.
26+
27+
## Supervisor
28+
29+
Supervisor configured to run SSH, Memcache, and Apache, but logging doesn't work correctly with 'docker logs' or 'fig logs'
30+
31+
Any thoughts?
32+
33+
## Other things included in image
34+
35+
* Drush
36+
* PHP-FPM :: Apache isn't configured to use this, but maybe at some point. PR's welcome!
37+
* git :: should probably remove this..
38+
39+
40+
## TODO
41+
* Clean yum cache and logs in Dockerfile
42+
* Set up PHP-FPM
43+
* Set up supervisor logging correctly
44+
* Set up volumes
45+
** What is useful for this? Just Files? entire sites directory?
46+
* Set up PHP configuration variables with environment, e.g. max_execution_time, memory_limit
47+
* SSH Root access should be revoked, need user/pass generation/env vars.

‎assets/crontab‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
0 */2 * * * apache /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COLUMNS=72 /usr/local/drush/drush --root=/var/www/html --quiet cron

‎assets/scripts/entrypoint.sh‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
WEB_ROOT=/var/www/html
4+
5+
function init_settings {
6+
# Initialize settings.php file
7+
cp "$WEB_ROOT/sites/default/default.settings.php" "$WEB_ROOT/sites/default/settings.php"
8+
chmod a+w "$WEB_ROOT/sites/default/settings.php"
9+
chmod a+w "$WEB_ROOT/sites/default"
10+
setenforce 0
11+
}
12+
13+
function init_db {
14+
# is a mysql or postgresql database linked?
15+
# requires that the mysql or postgresql containers have exposed
16+
# port 3306 and 5432 respectively.
17+
if [ -n "${MYSQL_PORT_3306_TCP_ADDR}" ]; then
18+
DB_TYPE=mysql
19+
DB_HOST=${DB_HOST:-${MYSQL_PORT_3306_TCP_ADDR}}
20+
DB_PORT=${DB_PORT:-${MYSQL_PORT_3306_TCP_PORT}}
21+
DB_PASS=${DB_PASS:-${MYSQL_ENV_MYSQL_PASSWORD}}
22+
DB_USER=${DB_USER:-${MYSQL_ENV_MYSQL_USER}}
23+
DB_NAME=${DB_NAME:-${MYSQL_ENV_MYSQL_DATABASE}}
24+
DB_DRIVER="mysql"
25+
elif [ -n "${MARIADB_PORT_3306_TCP_ADDR}" ]; then
26+
DB_TYPE=mysql
27+
DB_HOST=${DB_HOST:-${MARIADB_PORT_3306_TCP_ADDR}}
28+
DB_PORT=${DB_PORT:-${MARIADB_PORT_3306_TCP_PORT}}
29+
DB_PASS=${DB_PASS:-${MARIADB_ENV_MYSQL_PASSWORD}}
30+
DB_USER=${DB_USER:-${MARIADB_ENV_MYSQL_USER}}
31+
DB_NAME=${DB_NAME:-${MARIADB_ENV_MYSQL_DATABASE}}
32+
DB_DRIVER="mysql"
33+
34+
# elif [ -n "${POSTGRESQL_PORT_5432_TCP_ADDR}" ]; then
35+
# DB_TYPE=postgres
36+
# DB_HOST=${DB_HOST:-${POSTGRESQL_PORT_5432_TCP_ADDR}}
37+
# DB_PORT=${DB_PORT:-${POSTGRESQL_PORT_5432_TCP_PORT}}
38+
# # support for linked official postgres image
39+
# DB_USER=${DB_USER:-${POSTGRESQL_ENV_POSTGRES_USER}}
40+
# DB_PASS=${DB_PASS:-${POSTGRESQL_ENV_POSTGRES_PASS}}
41+
# DB_NAME=${DB_NAME:-${DB_USER}}
42+
# DB_DRIVER="pgsql"
43+
elif [ -n "${DB_DRIVER}" ] || [ -n "${DB_NAME}" ] || [ -n "${DB_HOST}"] || [ -n "${DB_USER}" ] || [ -n "${DB_PASS}" ]; then
44+
echo "Error: DB must be alias'ed correctly, or all DB parameters must be specified."
45+
exit 1
46+
fi
47+
48+
cat >> "$WEB_ROOT/sites/default/settings.php" <<- EOFDBSETTINGS
49+
\$databases['default']['default'] = array(
50+
'driver' => '$DB_DRIVER',
51+
'database' => "$DB_NAME",
52+
'username' => "$DB_USER",
53+
'password' => "$DB_PASS",
54+
'host' => "$DB_HOST",
55+
'prefix' => "$DB_PREFIX",
56+
);
57+
EOFDBSETTINGS
58+
}
59+
60+
function init_apache_php_settings {
61+
62+
PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-"1024M"}
63+
PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME:-"900"}
64+
PHP_POST_MAX_SIZE=${PHP_POST_MAX_SIZE:-"256M"}
65+
PHP_UPLOAD_MAX_FILE_SIZE=${PHP_UPLOAD_MAX_FILE_SIZE:-"256M"}
66+
PHP_MAX_FILE_UPLOADS=${PHP_MAX_FILE_UPLOADS:-"100"}
67+
sed -i \
68+
-e "s/^memory_limit.*$/memory_limit = $PHP_MEMORY_LIMIT/g" \
69+
-e "s/^max_execution_time.*$/max_execution_time = $PHP_MAX_EXECUTION_TIME/g" \
70+
-e "s/^session.save_handler.*$/session.save_handler = memcache/g" \
71+
-e "s/^post_max_size.*$/post_max_size = $PHP_POST_MAX_SIZE/g" \
72+
-e "s/^upload_max_file_size.*$/upload_max_file_size = $PHP_UPLOAD_MAX_FILE_SIZE/g" \
73+
-e "s/^max_file_uploads.*$/max_file_uploads = $PHP_MAX_FILE_UPLOADS/g" \
74+
/etc/php5/apache2/php.ini
75+
76+
}
77+
78+
function fix_perm {
79+
chmod 644 "$WEB_ROOT/sites/default/settings.php"
80+
chmod 755 "$WEB_ROOT/sites/default"
81+
}
82+
83+
if [ -e "/.bootstrap" ] ; then
84+
echo ".bootstrap file found. skipping initial configuration."
85+
else
86+
echo "Bootstrapping..."
87+
init_settings
88+
init_db
89+
90+
touch /.bootstrap
91+
fi
92+
93+
if [ -e "/.bootstrap" ] ; then
94+
supervisord
95+
fi

‎assets/scripts/set_root_pass.sh‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
4+
if [ -f /.root_pw_set ]; then
5+
echo "Root password already set!"
6+
exit 0
7+
fi
8+
9+
PASS=${ROOT_PASS:-$(pwgen -s 12 1)}
10+
_word=$( [ ${ROOT_PASS} ] && echo "preset" || echo "random" )
11+
12+
echo "=> Setting a ${_word} password to the root user"
13+
echo "root:$PASS" | chpasswd
14+
echo "=> Done!"
15+
touch /.root_pw_set
16+
17+
18+
echo "========================================================================"
19+
echo "You can now connect to this CentOS container via SSH using:"
20+
echo ""
21+
echo " ssh -p <port> root@<host>"
22+
echo "and enter the root password '$PASS' when prompted"
23+
echo ""
24+
echo "Please remember to change the above password as soon as possible!"
25+
echo "========================================================================"

‎assets/supervisor/supervisord.conf‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[supervisord]
2+
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
3+
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
4+
logfile_backups=10 ; (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+
minfds=1024 ; (min. avail startup file descriptors;default 1024)
9+
minprocs=200 ; (min. avail process descriptors;default 200)
10+
11+
12+
[program:sshd]
13+
command=/usr/sbin/sshd -D
14+
autorestart=true
15+
stdout_events_enabled = true
16+
stderr_events_enabled = true
17+
18+
[program:memcached]
19+
command=/usr/bin/memcached -p 11211 -u apache -m 64 -c 1024 -t 4
20+
autorestart=true
21+
stdout_events_enabled = true
22+
stderr_events_enabled = true
23+
24+
[program:apache2]
25+
command=/bin/bash -c "exec /usr/sbin/apachectl -DFOREGROUND"
26+
autorestart=true
27+
stdout_events_enabled = true
28+
stderr_events_enabled = true
29+
#redirect_stderr=true
30+
31+
[eventlistener:stdout]
32+
command = supervisor_stdout
33+
buffer_size = 100
34+
events = PROCESS_LOG
35+
result_handler = supervisor_stdout:event_handler

0 commit comments

Comments
 (0)