aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-06-16 23:46:33 +0200
committerVirtualTam <virtualtam@flibidi.net>2018-06-17 13:21:01 +0200
commitdecae8c119e0f4750d10909abc47d8afb89af362 (patch)
tree8a9587a53f0161fe95141d982ff4cea40075372b
parent865d57b84abb0fa3fc04aec7ce2d34326dac34fa (diff)
downloadShaarli-decae8c119e0f4750d10909abc47d8afb89af362.tar.gz
Shaarli-decae8c119e0f4750d10909abc47d8afb89af362.tar.zst
Shaarli-decae8c119e0f4750d10909abc47d8afb89af362.zip
docker: build the images from the local sources
Relates to https://github.com/shaarli/Shaarli/issues/1153 Signed-off-by: VirtualTam <virtualtam@flibidi.net>
-rw-r--r--.docker/.htaccess13
-rw-r--r--.docker/nginx.conf73
-rw-r--r--.docker/php-fpm.conf16
-rwxr-xr-x.docker/services.d/.s6-svscan/finish2
-rwxr-xr-x.docker/services.d/nginx/run2
-rwxr-xr-x.docker/services.d/php-fpm/run2
-rw-r--r--.dockerignore44
-rw-r--r--.gitattributes4
-rw-r--r--CHANGELOG.md7
-rw-r--r--Dockerfile61
-rw-r--r--Dockerfile.armhf50
11 files changed, 272 insertions, 2 deletions
diff --git a/.docker/.htaccess b/.docker/.htaccess
new file mode 100644
index 00000000..f601c1ee
--- /dev/null
+++ b/.docker/.htaccess
@@ -0,0 +1,13 @@
1<IfModule version_module>
2 <IfVersion >= 2.4>
3 Require all denied
4 </IfVersion>
5 <IfVersion < 2.4>
6 Allow from none
7 Deny from all
8 </IfVersion>
9</IfModule>
10
11<IfModule !version_module>
12 Require all denied
13</IfModule>
diff --git a/.docker/nginx.conf b/.docker/nginx.conf
new file mode 100644
index 00000000..07fba33f
--- /dev/null
+++ b/.docker/nginx.conf
@@ -0,0 +1,73 @@
1user nginx nginx;
2daemon off;
3worker_processes 4;
4pid /var/run/nginx.pid;
5
6events {
7 worker_connections 768;
8}
9
10http {
11 include mime.types;
12 default_type application/octet-stream;
13 keepalive_timeout 20;
14
15 client_max_body_size 10m;
16
17 index index.html index.php;
18
19 server {
20 listen 80;
21 root /var/www/shaarli;
22
23 access_log /var/log/nginx/shaarli.access.log;
24 error_log /var/log/nginx/shaarli.error.log;
25
26 location ~ /\. {
27 # deny access to dotfiles
28 access_log off;
29 log_not_found off;
30 deny all;
31 }
32
33 location ~ ~$ {
34 # deny access to temp editor files, e.g. "script.php~"
35 access_log off;
36 log_not_found off;
37 deny all;
38 }
39
40 location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
41 # cache static assets
42 expires max;
43 add_header Pragma public;
44 add_header Cache-Control "public, must-revalidate, proxy-revalidate";
45 }
46
47 location = /favicon.ico {
48 # serve the Shaarli favicon from its custom location
49 alias /var/www/shaarli/images/favicon.ico;
50 }
51
52 location / {
53 # Slim - rewrite URLs
54 try_files $uri /index.php$is_args$args;
55 }
56
57 location ~ (index)\.php$ {
58 # Slim - split URL path into (script_filename, path_info)
59 try_files $uri =404;
60 fastcgi_split_path_info ^(.+\.php)(/.+)$;
61
62 # filter and proxy PHP requests to PHP-FPM
63 fastcgi_pass unix:/var/run/php-fpm.sock;
64 fastcgi_index index.php;
65 include fastcgi.conf;
66 }
67
68 location ~ \.php$ {
69 # deny access to all other PHP scripts
70 deny all;
71 }
72 }
73}
diff --git a/.docker/php-fpm.conf b/.docker/php-fpm.conf
new file mode 100644
index 00000000..0843c164
--- /dev/null
+++ b/.docker/php-fpm.conf
@@ -0,0 +1,16 @@
1[global]
2daemonize = no
3
4[www]
5user = nginx
6group = nginx
7listen.owner = nginx
8listen.group = nginx
9catch_workers_output = yes
10listen = /var/run/php-fpm.sock
11pm = dynamic
12pm.max_children = 20
13pm.start_servers = 1
14pm.min_spare_servers = 1
15pm.max_spare_servers = 3
16pm.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..1dadeeaf
--- /dev/null
+++ b/.docker/services.d/.s6-svscan/finish
@@ -0,0 +1,2 @@
1#!/bin/sh
2/bin/true
diff --git a/.docker/services.d/nginx/run b/.docker/services.d/nginx/run
new file mode 100755
index 00000000..21e7b0d6
--- /dev/null
+++ b/.docker/services.d/nginx/run
@@ -0,0 +1,2 @@
1#!/bin/execlineb -P
2nginx
diff --git a/.docker/services.d/php-fpm/run b/.docker/services.d/php-fpm/run
new file mode 100755
index 00000000..21dd0107
--- /dev/null
+++ b/.docker/services.d/php-fpm/run
@@ -0,0 +1,2 @@
1#!/bin/execlineb -P
2php-fpm7 -F
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..cdd0a894
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,44 @@
1# Docker-ignore
2.dev
3.git
4.github
5tests
6
7# Shaarli runtime resources
8cache/*
9data/*
10pagecache/*
11tmp/*
12
13# Eclipse project files
14.settings
15.buildpath
16.project
17
18# Raintpl generated pages
19*.rtpl.php
20
21# 3rd-party dependencies
22vendor/
23
24# Release archives
25*.tar.gz
26*.zip
27inc/languages/*/LC_MESSAGES/shaarli.mo
28
29# Development and test resources
30coverage
31doxygen
32sandbox
33phpmd.html
34
35# User plugin configuration
36plugins/*/config.php
37
38# HTML documentation
39doc/html/
40
41# 3rd party themes
42tpl/*
43!tpl/default
44!tpl/vintage
diff --git a/.gitattributes b/.gitattributes
index b191e227..00070561 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -32,7 +32,9 @@ Dockerfile text
32.travis.yml export-ignore 32.travis.yml export-ignore
33doc/**/*.json export-ignore 33doc/**/*.json export-ignore
34doc/**/*.md export-ignore 34doc/**/*.md export-ignore
35docker/ export-ignore 35.docker/ export-ignore
36.dockerignore export-ignore
37Dockerfile* export-ignore
36Doxyfile export-ignore 38Doxyfile export-ignore
37Makefile export-ignore 39Makefile export-ignore
38mkdocs.yml export-ignore 40mkdocs.yml export-ignore
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14a4f143..4f72436b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,8 +4,13 @@ All notable changes to this project will be documented in this file.
4The format is based on [Keep a Changelog](http://keepachangelog.com/) 4The format is based on [Keep a Changelog](http://keepachangelog.com/)
5and this project adheres to [Semantic Versioning](http://semver.org/). 5and this project adheres to [Semantic Versioning](http://semver.org/).
6 6
7## [v0.9.7](https://github.com/shaarli/Shaarli/releases/tag/v0.9.7) - UNPUBLISHED
8### Changed
9- Build the Docker images from the local Git sources
10
11
7## [v0.9.6](https://github.com/shaarli/Shaarli/releases/tag/v0.9.6) - 2018-03-25 12## [v0.9.6](https://github.com/shaarli/Shaarli/releases/tag/v0.9.6) - 2018-03-25
8## Changed 13### Changed
9- htaccess: prevent accessing resources not managed by SCM 14- htaccess: prevent accessing resources not managed by SCM
10- htaccess: always forward the 'Authorization' HTTP header 15- htaccess: always forward the 'Authorization' HTTP header
11 16
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..93146c52
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,61 @@
1# Stage 1:
2# - Copy Shaarli sources
3# - Build documentation
4FROM python:3-alpine as docs
5ADD . /usr/src/app/shaarli
6RUN cd /usr/src/app/shaarli \
7 && pip install --no-cache-dir mkdocs \
8 && mkdocs build
9
10# Stage 2:
11# - Resolve PHP dependencies with Composer
12FROM composer:latest as composer
13COPY --from=docs /usr/src/app/shaarli /app/shaarli
14RUN cd shaarli \
15 && composer --prefer-dist --no-dev install
16
17# Stage 3:
18# - Shaarli image
19FROM alpine:3.6
20LABEL maintainer="Shaarli Community"
21
22RUN apk --update --no-cache add \
23 ca-certificates \
24 nginx \
25 php7 \
26 php7-ctype \
27 php7-curl \
28 php7-fpm \
29 php7-gd \
30 php7-iconv \
31 php7-intl \
32 php7-json \
33 php7-mbstring \
34 php7-openssl \
35 php7-session \
36 php7-xml \
37 php7-zlib \
38 s6
39
40COPY .docker/nginx.conf /etc/nginx/nginx.conf
41COPY .docker/php-fpm.conf /etc/php7/php-fpm.conf
42COPY .docker/services.d /etc/services.d
43
44RUN rm -rf /etc/php7/php-fpm.d/www.conf \
45 && sed -i 's/post_max_size.*/post_max_size = 10M/' /etc/php7/php.ini \
46 && sed -i 's/upload_max_filesize.*/upload_max_filesize = 10M/' /etc/php7/php.ini
47
48
49WORKDIR /var/www
50COPY --from=composer /app/shaarli shaarli
51
52RUN chown -R nginx:nginx . \
53 && ln -sf /dev/stdout /var/log/nginx/shaarli.access.log \
54 && ln -sf /dev/stderr /var/log/nginx/shaarli.error.log
55
56VOLUME /var/www/shaarli/data
57
58EXPOSE 80
59
60ENTRYPOINT ["/bin/s6-svscan", "/etc/services.d"]
61CMD []
diff --git a/Dockerfile.armhf b/Dockerfile.armhf
new file mode 100644
index 00000000..24695633
--- /dev/null
+++ b/Dockerfile.armhf
@@ -0,0 +1,50 @@
1FROM lsiobase/alpine.armhf:3.6
2LABEL maintainer="Shaarli Community"
3MAINTAINER Shaarli Community
4
5RUN apk --update --no-cache add \
6 ca-certificates \
7 curl \
8 nginx \
9 php7 \
10 php7-ctype \
11 php7-curl \
12 php7-fpm \
13 php7-gd \
14 php7-iconv \
15 php7-intl \
16 php7-json \
17 php7-mbstring \
18 php7-openssl \
19 php7-phar \
20 php7-session \
21 php7-xml \
22 php7-zlib \
23 s6
24
25COPY .docker/nginx.conf /etc/nginx/nginx.conf
26COPY .docker/php-fpm.conf /etc/php7/php-fpm.conf
27COPY .docker/services.d /etc/services.d
28
29RUN curl -sS https://getcomposer.org/installer | php7 -- --install-dir=/usr/local/bin --filename=composer \
30 && rm -rf /etc/php7/php-fpm.d/www.conf \
31 && sed -i 's/post_max_size.*/post_max_size = 10M/' /etc/php7/php.ini \
32 && sed -i 's/upload_max_filesize.*/upload_max_filesize = 10M/' /etc/php7/php.ini
33
34
35WORKDIR /var/www
36RUN curl -L https://github.com/shaarli/Shaarli/archive/latest.tar.gz | tar xzf - \
37 && mv Shaarli-latest shaarli \
38 && cd shaarli \
39 && composer --prefer-dist --no-dev install \
40 && rm -rf ~/.composer \
41 && chown -R nginx:nginx . \
42 && ln -sf /dev/stdout /var/log/nginx/shaarli.access.log \
43 && ln -sf /dev/stderr /var/log/nginx/shaarli.error.log
44
45VOLUME /var/www/shaarli/data
46
47EXPOSE 80
48
49ENTRYPOINT ["/bin/s6-svscan", "/etc/services.d"]
50CMD []