summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2017-11-30 16:47:52 -0800
committerFrédéric Guillot <fred@kanboard.net>2017-11-30 16:55:53 -0800
commit55547db6ce691a71d19a502178c2a9e00a303dd5 (patch)
tree41197ca843b9b0d5f47e6b22e5bcc00a4aa37b68
parent12202f04511c14844641edce879afd81e10e767b (diff)
Improve docker build to use hooks
-rw-r--r--.dockerignore1
-rw-r--r--.gitattributes1
-rw-r--r--Dockerfile36
-rw-r--r--Makefile8
-rw-r--r--docker/etc/nginx/nginx.conf69
-rw-r--r--docker/etc/php7/conf.d/local.ini15
-rw-r--r--docker/etc/php7/php-fpm.conf19
-rw-r--r--docker/etc/php7/php-fpm.d/env.conf (renamed from docker/php/env.conf)0
-rwxr-xr-xdocker/etc/services.d/.s6-svscan/finish2
-rwxr-xr-xdocker/etc/services.d/cron/run (renamed from docker/services.d/cron/run)0
-rwxr-xr-xdocker/etc/services.d/nginx/run3
-rwxr-xr-xdocker/etc/services.d/php/run2
-rw-r--r--docker/kanboard/config.php4
-rwxr-xr-xdocker/usr/local/bin/entrypoint.sh6
-rw-r--r--docker/var/spool/crontabs/nginx (renamed from docker/crontab/cronjob.alpine)0
-rwxr-xr-xhooks/build15
16 files changed, 161 insertions, 20 deletions
diff --git a/.dockerignore b/.dockerignore
index 46051a1f..58a7e413 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -17,3 +17,4 @@ Vagrantfile
web.config
bower_components
node_modules
+hooks \ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
index 5ca66a71..ef869b16 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -21,6 +21,7 @@ composer.json export-ignore
composer.lock export-ignore
gulpfile.js export-ignore
package.json export-ignore
+hooks export-ignore
assets/sass export-ignore
assets/js/components export-ignore
diff --git a/Dockerfile b/Dockerfile
index e1d4d52a..bdea1f22 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,12 +1,30 @@
-FROM fguillot/alpine-nginx-php7
-
-COPY . /var/www/app
-COPY docker/kanboard/config.php /var/www/app/config.php
-COPY docker/crontab/cronjob.alpine /var/spool/cron/crontabs/nginx
-COPY docker/services.d/cron /etc/services.d/cron
-COPY docker/php/env.conf /etc/php7/php-fpm.d/env.conf
-
-RUN chown -R nginx:nginx /var/www/app/data /var/www/app/plugins
+FROM alpine:3.6
VOLUME /var/www/app/data
VOLUME /var/www/app/plugins
+
+EXPOSE 80
+
+ARG VERSION
+
+RUN apk update && \
+ apk add unzip nginx bash ca-certificates s6 curl ssmtp mailx php7 php7-phar php7-curl \
+ php7-fpm php7-json php7-zlib php7-xml php7-dom php7-ctype php7-opcache php7-zip php7-iconv \
+ php7-pdo php7-pdo_mysql php7-pdo_sqlite php7-pdo_pgsql php7-mbstring php7-session \
+ php7-gd php7-mcrypt php7-openssl php7-sockets php7-posix php7-ldap php7-simplexml && \
+ rm -rf /var/cache/apk/* && \
+ rm -rf /var/www/localhost && \
+ rm -f /etc/php7/php-fpm.d/www.conf
+
+RUN cd /tmp \
+ && curl -sL -o kb.zip https://github.com/kanboard/kanboard/archive/$VERSION.zip \
+ && unzip -qq kb.zip \
+ && cd kanboard-* \
+ && cp -R . /var/www/app \
+ && cd /tmp \
+ && rm -rf /tmp/kanboard-* /tmp/*.zip
+
+ADD docker/ /
+
+ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+CMD []
diff --git a/Makefile b/Makefile
index c73ab68c..d583ad0d 100644
--- a/Makefile
+++ b/Makefile
@@ -73,12 +73,6 @@ sql:
@ grep -v "SET idle_in_transaction_session_timeout = 0;" app/Schema/Sql/postgres.sql > temp && mv temp 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
+ @ IMAGE_NAME=kanboard/kanboard:latest ./hooks/build
.PHONY: all
diff --git a/docker/etc/nginx/nginx.conf b/docker/etc/nginx/nginx.conf
new file mode 100644
index 00000000..6ba545f6
--- /dev/null
+++ b/docker/etc/nginx/nginx.conf
@@ -0,0 +1,69 @@
+user nginx;
+worker_processes 1;
+pid /var/run/nginx.pid;
+
+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/app;
+ client_max_body_size 32M;
+
+ 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 ~* ^.+\.(log|sqlite)$ {
+ return 404;
+ }
+
+ location ~ /\.ht {
+ return 404;
+ }
+
+ location ~* ^.+\.(ico|jpg|gif|png|css|js|svg|eot|ttf|woff|woff2|otf)$ {
+ log_not_found off;
+ 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/etc/php7/conf.d/local.ini b/docker/etc/php7/conf.d/local.ini
new file mode 100644
index 00000000..0c1795f2
--- /dev/null
+++ b/docker/etc/php7/conf.d/local.ini
@@ -0,0 +1,15 @@
+expose_php = Off
+error_reporting = E_ALL
+display_errors = Off
+log_errors = On
+error_log = /dev/stderr
+date.timezone = UTC
+allow_url_fopen = On
+post_max_size = 32M
+upload_max_filesize = 32M
+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
diff --git a/docker/etc/php7/php-fpm.conf b/docker/etc/php7/php-fpm.conf
new file mode 100644
index 00000000..ea227529
--- /dev/null
+++ b/docker/etc/php7/php-fpm.conf
@@ -0,0 +1,19 @@
+[global]
+error_log = /proc/self/fd/2
+log_level = error
+daemonize = no
+
+[www]
+catch_workers_output = yes
+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
+include = /etc/php7/php-fpm.d/env.conf \ No newline at end of file
diff --git a/docker/php/env.conf b/docker/etc/php7/php-fpm.d/env.conf
index 23f6ce3d..23f6ce3d 100644
--- a/docker/php/env.conf
+++ b/docker/etc/php7/php-fpm.d/env.conf
diff --git a/docker/etc/services.d/.s6-svscan/finish b/docker/etc/services.d/.s6-svscan/finish
new file mode 100755
index 00000000..fc3b1e93
--- /dev/null
+++ b/docker/etc/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/etc/services.d/cron/run
index da378099..da378099 100755
--- a/docker/services.d/cron/run
+++ b/docker/etc/services.d/cron/run
diff --git a/docker/etc/services.d/nginx/run b/docker/etc/services.d/nginx/run
new file mode 100755
index 00000000..7478cd75
--- /dev/null
+++ b/docker/etc/services.d/nginx/run
@@ -0,0 +1,3 @@
+#!/bin/execlineb -P
+
+nginx -g "daemon off;" \ No newline at end of file
diff --git a/docker/etc/services.d/php/run b/docker/etc/services.d/php/run
new file mode 100755
index 00000000..6b093238
--- /dev/null
+++ b/docker/etc/services.d/php/run
@@ -0,0 +1,2 @@
+#!/bin/execlineb -P
+php-fpm7 -F \ No newline at end of file
diff --git a/docker/kanboard/config.php b/docker/kanboard/config.php
deleted file mode 100644
index 58daff48..00000000
--- a/docker/kanboard/config.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-
-define('ENABLE_URL_REWRITE', true);
-define('LOG_DRIVER', 'stderr');
diff --git a/docker/usr/local/bin/entrypoint.sh b/docker/usr/local/bin/entrypoint.sh
new file mode 100755
index 00000000..fe49c41b
--- /dev/null
+++ b/docker/usr/local/bin/entrypoint.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+chown -R nginx:nginx /var/www/app/data
+chown -R nginx:nginx /var/www/app/plugins
+
+exec /bin/s6-svscan /etc/services.d
diff --git a/docker/crontab/cronjob.alpine b/docker/var/spool/crontabs/nginx
index e92aa0e3..e92aa0e3 100644
--- a/docker/crontab/cronjob.alpine
+++ b/docker/var/spool/crontabs/nginx
diff --git a/hooks/build b/hooks/build
new file mode 100755
index 00000000..043be1f7
--- /dev/null
+++ b/hooks/build
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+VERSION=master
+
+if [ "$SOURCE_BRANCH" != "" ]; then
+ VERSION=$SOURCE_BRANCH
+
+ if [ "$SOURCE_BRANCH" == "latest" ]; then
+ VERSION=master
+ fi
+fi
+
+echo "Building $VERSION"
+
+docker build --build-arg VERSION=$VERSION -t $IMAGE_NAME .