initial commit

master
Michał 'rysiek' Woźniak 2015-01-04 17:04:51 +01:00
commit f4d6db60e2
5 changed files with 185 additions and 0 deletions

60
php-fpm/Dockerfile Normal file
View File

@ -0,0 +1,60 @@
FROM debian:jessie
MAINTAINER Michał "rysiek" Woźniak <rysiek@hackerspace.pl>
# based on https://github.com/leoditommaso/docker_php-fpm/blob/master/Dockerfile
# by Leandro Di Tommaso <leandro.ditommaso@mikroways.net>
# Packages to install on the container.
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade && apt-get install -y \
php5-cgi php5-cli php5-fpm php5-curl php5-gd php5-imagick php5-imap \
php5-json php5-ldap php5-mcrypt php5-pgsql php5-odbc php5-sasl \
php5-xcache php5-xmlrpc php5-xsl
# Define environment variables.
# Change the following to rename your app or change the user and group the app will run
# with. I don't recommend modifying the user and group but there's no problem in changing
# the app name.
ENV APP_NAME www
ENV APP_USER www-data
ENV APP_GROUP www-data
# Create directory for the application.
#RUN mkdir -p /opt/applications
# log and run
RUN mkdir -p /var/log/phpfpm && chown $APP_USER:$APP_GROUP /var/log/phpfpm
RUN mkdir -p /var/run/phpfpm && chown $APP_USER:$APP_GROUP /var/run/phpfpm
# php.ini customizations.
RUN sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 10M/g" /etc/php5/fpm/php.ini
RUN sed -i "s/post_max_size = 8M/post_max_size = 10M/g" /etc/php5/fpm/php.ini
# PHP-FPM pool configuration.
RUN rm /etc/php5/fpm/pool.d/www.conf
ADD pool.conf /etc/php5/fpm/pool.d/pool.conf
RUN mv /etc/php5/fpm/pool.d/pool.conf /etc/php5/fpm/pool.d/$APP_NAME.conf
RUN sed -i "s/pool_name/$APP_NAME/g" /etc/php5/fpm/pool.d/$APP_NAME.conf && \
sed -i "s/app_user/$APP_USER/g" /etc/php5/fpm/pool.d/$APP_NAME.conf && \
sed -i "s/app_group/$APP_GROUP/g" /etc/php5/fpm/pool.d/$APP_NAME.conf
# Change the default error log location.
RUN sed -i "s@error_log = /var/log/php5-fpm.log@error_log = /var/log/phpfpm/$APP_NAME-php-fpm5.access.log@g" /etc/php5/fpm/php-fpm.conf
# info
RUN echo " \n\
\n\
******************************************************** \n\
RUNNING THE CONTAINER: \n\
docker run -d -v <socket_dir>:/var/run/phpfpm -v <log_dir>:/var/log/phpfpm -v <php_dir>:/opt/php --name <plug-php-fpm> <plug/php-fpm> \n\
\n\
ENVIRONMENT VARIABLES: \n\
APP_NAME - name of the app; default: www \n\
APP_USER - username for the php-fpm processes; default: www-data \n\
APP_USER - group name for the php-fpm processes; default: www-data \n\
******************************************************** \n\n\
"
VOLUME ["/var/run/phpfpm/", "/var/log/phpfpm/", "/opt/php"]
CMD []
ENTRYPOINT ["/usr/sbin/php5-fpm", "-F", "--fpm-config", "/etc/php5/fpm/php-fpm.conf"]

50
php-fpm/pool.conf Normal file
View File

@ -0,0 +1,50 @@
[pool_name]
; based on https://github.com/leoditommaso/docker_php-fpm/blob/master/Dockerfile
; by Leandro Di Tommaso <leandro.ditommaso@mikroways.net>
; Unix user/group of processes
user = app_user
group = app_group
; Chdir to this directory at the start.
chdir = /
; The address on which to accept FastCGI requests.
listen = /var/run/phpfpm/$pool-php5-fpm.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
listen.backlog = -1
; Set permissions for unix socket.
listen.mode = 0666
; Pool configuration.
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 500
; The URI to view the FPM status page.
pm.status_path = /status
; The ping URI to call the monitoring page of FPM.
ping.path = /ping
; The access log file.
access.log = /var/log/phpfpm/$pool-php-fpm5.access.log
; The access log format.
access.format = "%R - %u %t %m %r%Q%q %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests.
slowlog = /var/log/phpfpm/$pool-php5-fpm.log.slow
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
request_slowlog_timeout = 5
; Limits the extensions of the main script FPM will allow to parse.
security.limit_extensions = .php

47
postgres/Dockerfile Normal file
View File

@ -0,0 +1,47 @@
#
# based on the example Dockerfile for http://docs.docker.com/examples/postgresql_service/
#
FROM debian:jessie
MAINTAINER Michał "rysiek" Woźniak <rysiek@hackerspace.pl>
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.3``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get upgrade && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# Only quassel needs to connectm eh?
# TEMPORARY
RUN echo "host any any 172.17.0.0/16 trust" >> /etc/postgresql/9.3/main/pg_hba.conf
# Well...
#RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
# prep script
ADD prep.sh /root/prep.sh
# just in case this is a test drive -- production environments will need to re-run prep.sh for the external volume
RUN ls -l /root && /bin/bash /root/prep.sh
# Expose the PostgreSQL port
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/var/lib/postgresql/"]
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
USER postgres
# Set the default command to run when starting the container
CMD []
ENTRYPOINT ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/etc/postgresql/9.3/main/"]

4
postgres/data/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
9.3*
# Except this file
!.gitignore

24
postgres/prep.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# removing the database cluster if it exists and prepping everything for posgresql operation
# be careful, Will Robinson!
# we need to be root for this
if [[ `whoami` != 'root' ]]; then
echo "we need to be root for this, quitting"
exit 1
fi
# work the directory
cd /var/lib/postgresql
chown postgres:postgres ./
chmod 0700 ./
# initdb as postgres
su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres
# let quassel db
/etc/init.d/postgresql start
su -c 'psql --command "CREATE USER quassel;"' postgres
su -c "psql --command \"CREATE DATABASE quassel WITH OWNER quassel TEMPLATE template0 ENCODING 'UTF8';\"" postgres
/etc/init.d/postgresql stop