diff options
-rw-r--r-- | .docker/crontab/kanboard | 1 | ||||
-rw-r--r-- | .docker/nginx/nginx.conf | 70 | ||||
-rw-r--r-- | .docker/php/conf.d/local.ini | 15 | ||||
-rw-r--r-- | .docker/php/php-fpm.conf | 17 | ||||
-rwxr-xr-x | .docker/services.d/.s6-svscan/finish | 2 | ||||
-rwxr-xr-x | .docker/services.d/cron/run | 2 | ||||
-rwxr-xr-x | .docker/services.d/nginx/run | 2 | ||||
-rwxr-xr-x | .docker/services.d/php/run | 2 | ||||
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | Dockerfile | 42 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | doc/docker.markdown | 45 |
12 files changed, 183 insertions, 26 deletions
diff --git a/.docker/crontab/kanboard b/.docker/crontab/kanboard new file mode 100644 index 00000000..91ad044e --- /dev/null +++ b/.docker/crontab/kanboard @@ -0,0 +1 @@ +1 0 * * * cd /var/www/kanboard && ./kanboard cronjob >/dev/null 2>&1 diff --git a/.docker/nginx/nginx.conf b/.docker/nginx/nginx.conf new file mode 100644 index 00000000..a09e8e12 --- /dev/null +++ b/.docker/nginx/nginx.conf @@ -0,0 +1,70 @@ +user nginx; +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + server_tokens off; + access_log off; + error_log /dev/stderr; + + server { + listen 80; + server_name localhost; + index index.php; + root /var/www/kanboard; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_index index.php; + include fastcgi_params; + } + + location /data { + return 404; + } + + location ~* ^.+\.(log|sqlite)$ { + return 404; + } + + location ~ /\.ht { + return 404; + } + + location ~* ^.+\.(ico|jpg|gif|png|css|js|svg|eot|ttf|woff|woff2|otf)$ { + expires 7d; + etag on; + } + + gzip on; + gzip_comp_level 3; + gzip_disable "msie6"; + gzip_vary on; + gzip_types + text/javascript + application/javascript + application/json + text/xml + application/xml + application/rss+xml + text/css + text/plain; + } +} diff --git a/.docker/php/conf.d/local.ini b/.docker/php/conf.d/local.ini new file mode 100644 index 00000000..12d22cc6 --- /dev/null +++ b/.docker/php/conf.d/local.ini @@ -0,0 +1,15 @@ +expose_php = Off +error_reporting = E_ALL +display_errors = Off +log_errors = On +error_log = syslog +date.timezone = UTC +allow_url_fopen = On +post_max_size = 30M +upload_max_filesize = 30M +opcache.max_accelerated_files = 7963 +opcache.validate_timestamps = Off +opcache.save_comments = 0 +opcache.load_comments = 0 +opcache.fast_shutdown = 1 +opcache.enable_file_override = On
\ No newline at end of file diff --git a/.docker/php/php-fpm.conf b/.docker/php/php-fpm.conf new file mode 100644 index 00000000..9e7ccd9c --- /dev/null +++ b/.docker/php/php-fpm.conf @@ -0,0 +1,17 @@ +[global] +error_log = /dev/stderr +log_level = error +daemonize = no + +[www] +user = nginx +group = nginx +listen.owner = nginx +listen.group = nginx +listen = /var/run/php-fpm.sock +pm = dynamic +pm.max_children = 20 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +pm.max_requests = 2048 diff --git a/.docker/services.d/.s6-svscan/finish b/.docker/services.d/.s6-svscan/finish new file mode 100755 index 00000000..fc3b1e93 --- /dev/null +++ b/.docker/services.d/.s6-svscan/finish @@ -0,0 +1,2 @@ +#!/bin/sh +/bin/true
\ No newline at end of file diff --git a/.docker/services.d/cron/run b/.docker/services.d/cron/run new file mode 100755 index 00000000..da378099 --- /dev/null +++ b/.docker/services.d/cron/run @@ -0,0 +1,2 @@ +#!/bin/execlineb -P +crond -f
\ No newline at end of file diff --git a/.docker/services.d/nginx/run b/.docker/services.d/nginx/run new file mode 100755 index 00000000..40a8b54a --- /dev/null +++ b/.docker/services.d/nginx/run @@ -0,0 +1,2 @@ +#!/bin/execlineb -P +nginx -g "daemon off;"
\ No newline at end of file diff --git a/.docker/services.d/php/run b/.docker/services.d/php/run new file mode 100755 index 00000000..e7d2dadd --- /dev/null +++ b/.docker/services.d/php/run @@ -0,0 +1,2 @@ +#!/bin/execlineb -P +php-fpm -F
\ No newline at end of file @@ -23,6 +23,7 @@ New features: Improvements: +* New Dockerfile based on Alpine Linux and Nginx/PHP-FPM * The date time format can be chosen in application settings * Export only open tasks in iCal feed * Remove time form on task summary page and move that to task edit form @@ -1,23 +1,33 @@ -FROM ubuntu:14.04 +FROM gliderlabs/alpine:latest MAINTAINER Frederic Guillot <fred@kanboard.net> -RUN apt-get update && apt-get install -y apache2 php5 php5-gd php5-ldap php5-sqlite git curl && apt-get clean -RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf && a2enmod rewrite -RUN sed -ri 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf -RUN curl -sS https://getcomposer.org/installer | php -- --filename=/usr/local/bin/composer -RUN cd /var/www && git clone --depth 1 https://github.com/fguillot/kanboard.git -RUN cd /var/www/kanboard && composer --prefer-dist --no-dev --optimize-autoloader --quiet install -RUN rm -rf /var/www/html && mv /var/www/kanboard /var/www/html -RUN chown -R www-data:www-data /var/www/html/data +RUN apk-install nginx bash ca-certificates s6 curl \ + php-fpm php-json php-zlib php-xml php-dom php-ctype php-opcache php-zip \ + php-pdo php-pdo_mysql php-pdo_sqlite php-pdo_pgsql php-ldap \ + php-gd php-mcrypt php-openssl php-phar \ + && curl -sS https://getcomposer.org/installer | php -- --filename=/usr/local/bin/composer -VOLUME /var/www/html/data +RUN cd /var/www \ + && wget https://github.com/fguillot/kanboard/archive/master.zip \ + && unzip -qq master.zip \ + && rm -f *.zip \ + && mv kanboard-master kanboard \ + && cd /var/www/kanboard && composer --prefer-dist --no-dev --optimize-autoloader --quiet install \ + && chown -R nginx:nginx /var/www/kanboard \ + && chown -R nginx:nginx /var/lib/nginx + +COPY .docker/services.d /etc/services.d +COPY .docker/php/conf.d/local.ini /etc/php/conf.d/ +COPY .docker/php/php-fpm.conf /etc/php/ +COPY .docker/nginx/nginx.conf /etc/nginx/ +COPY .docker/kanboard/config.php /var/www/kanboard/ +COPY .docker/kanboard/config.php /var/www/kanboard/ +COPY .docker/crontab/kanboard /var/spool/cron/crontabs/nginx EXPOSE 80 -ENV APACHE_RUN_USER www-data -ENV APACHE_RUN_GROUP www-data -ENV APACHE_LOG_DIR /var/log/apache2 -ENV APACHE_LOCK_DIR /var/lock/apache2 -ENV APACHE_PID_FILE /var/run/apache2.pid +VOLUME /var/www/kanboard/data +VOLUME /var/www/kanboard/plugins -CMD /usr/sbin/apache2ctl -D FOREGROUND +ENTRYPOINT ["/bin/s6-svscan", "/etc/services.d"] +CMD [] @@ -62,6 +62,7 @@ archive: @ rm -rf ${BUILD_DIR}/kanboard/*.markdown @ rm -rf ${BUILD_DIR}/kanboard/*.lock @ rm -rf ${BUILD_DIR}/kanboard/*.json + @ rm -rf ${BUILD_DIR}/kanboard/.docker @ cd ${BUILD_DIR}/kanboard && find ./vendor -name doc -type d -exec rm -rf {} +; @ cd ${BUILD_DIR}/kanboard && find ./vendor -name notes -type d -exec rm -rf {} +; @ cd ${BUILD_DIR}/kanboard && find ./vendor -name test -type d -exec rm -rf {} +; @@ -134,4 +135,13 @@ sql: @ let pg_version=`psql -U postgres -A -c 'copy(select version from schema_version) to stdout;' kanboard` ;\ echo "INSERT INTO schema_version VALUES ('$$pg_version');" >> app/Schema/Sql/postgres.sql +docker-image: + @ docker build -t kanboard/kanboard:latest . + +docker-push: + @ docker push kanboard/kanboard:latest + +docker-run: + @ docker run -d --name kanboard -p 80:80 -t kanboard/kanboard:latest + .PHONY: all diff --git a/doc/docker.markdown b/doc/docker.markdown index fe72a6c8..6bd966d3 100644 --- a/doc/docker.markdown +++ b/doc/docker.markdown @@ -2,7 +2,18 @@ How to run Kanboard with Docker? ================================ Kanboard can run easily with [Docker](https://www.docker.com). -There is a `Dockerfile` in the repository to build your own container. + +The image size is approximately **50MB** and contains: + +- [Alpine Linux](http://alpinelinux.org/) +- The [process manager S6](http://skarnet.org/software/s6/) +- Nginx +- PHP-FPM + +The Kanboard cronjob is also running everyday at midnight. +URL rewriting is enabled in the included config file. + +When the container is running, the memory utilization is around **20MB**. Use the stable version ---------------------- @@ -17,7 +28,7 @@ docker run -d --name kanboard -p 80:80 -t kanboard/kanboard:stable Use the development version (automated build) --------------------------------------------- -Every new commit on the repository trigger a new build on [Docker Hub](https://registry.hub.docker.com/u/kanboard/kanboard/). +Every new commit on the repository trigger a new build on the [Docker Hub](https://registry.hub.docker.com/u/kanboard/kanboard/). ```bash docker pull kanboard/kanboard @@ -29,31 +40,45 @@ The tag **latest** is the **development version** of Kanboard, use at your own r Build your own Docker image --------------------------- +There is a `Dockerfile` in the Kanboard repository to build your own image. Clone the Kanboard repository and run the following command: ```bash docker build -t youruser/kanboard:master . ``` -To run your image in background on the port 80: +or ```bash -docker run -d --name kanboard -p 80:80 -t youruser/kanboard:master +make docker-image ``` -Store your data on a volume ---------------------------- - -By default Kanboard will store attachments and the Sqlite database in the directory data. Run this command to use a custom volume path: +To run your container in background on the port 80: ```bash -docker run -d --name kanboard -v /your/local/data/folder:/var/www/html/data -p 80:80 -t kanboard/kanboard:master +docker run -d --name kanboard -p 80:80 -t youruser/kanboard:master ``` +Volumes +------- + +You can attach 2 volumes to your container: + +- Data folder: `/var/www/kanboard/data` +- Plugins folder: `/var/www/kanboard/plugins` + +Use the flag `-v` to mount a volume on the host machine like described in [official Docker documentation](https://docs.docker.com/engine/userguide/containers/dockervolumes/). + +Config files +------------ + +- The container already include a custom config file located at `/var/www/kanboard/config.php`. +- You can store your own config file on the data volume: `/var/www/kanboard/data/config.php`. + References ---------- - [Official Kanboard images](https://registry.hub.docker.com/u/kanboard/kanboard/) - [Docker documentation](https://docs.docker.com/) -- [Dockerfile stable version](https://github.com/kanboard/docker/blob/master/Dockerfile) +- [Dockerfile stable version](https://github.com/kanboard/docker) - [Dockerfile dev version](https://github.com/fguillot/kanboard/blob/master/Dockerfile) |