chore(): migrate to wonderfall/nginx-php #11

pull/14/head
Hardware 2017-05-13 11:12:25 +02:00
parent 6f73d4bbc8
commit 8e427b8dd0
No known key found for this signature in database
GPG Key ID: EC6DF6F90263EDEA
13 changed files with 96 additions and 193 deletions

View File

@ -1,36 +1,13 @@
FROM alpine:edge FROM wonderfall/nginx-php
LABEL description "Next-generation forum software that makes online discussion fun" \ LABEL description "Next-generation forum software that makes online discussion fun" \
maintainer="Hardware <hardware@mondedie.fr>, Magicalex <magicalex@mondedie.fr>" maintainer="Hardware <hardware@mondedie.fr>, Magicalex <magicalex@mondedie.fr>"
ARG VERSION=v0.1.0-beta.6 ARG VERSION=v0.1.0-beta.6
ENV GID=991 UID=991 ENV GID=991 UID=991 UPLOAD_MAX_SIZE=50M MEMORY_LIMIT=128M
RUN echo "@testing https://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ RUN apk add -U curl \
&& apk add -U \
nginx \
s6 \
su-exec \
curl \
php7@testing \
php7-fileinfo@testing \
php7-phar@testing \
php7-fpm@testing \
php7-curl@testing \
php7-mbstring@testing \
php7-openssl@testing \
php7-json@testing \
php7-pdo@testing \
php7-pdo_mysql@testing \
php7-mysqlnd@testing \
php7-zlib@testing \
php7-gd@testing \
php7-dom@testing \
php7-ctype@testing \
php7-session@testing \
php7-opcache@testing \
php7-xmlwriter@testing \
&& cd /tmp \ && cd /tmp \
&& curl -s http://getcomposer.org/installer | php \ && curl -s http://getcomposer.org/installer | php \
&& mv /tmp/composer.phar /usr/bin/composer \ && mv /tmp/composer.phar /usr/bin/composer \
@ -46,18 +23,8 @@ RUN echo "@testing https://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/r
&& composer clear-cache \ && composer clear-cache \
&& rm -rf /flarum/.composer /var/cache/apk/* && rm -rf /flarum/.composer /var/cache/apk/*
COPY nginx.conf /etc/nginx/nginx.conf COPY rootfs /
COPY php-fpm.conf /etc/php7/php-fpm.conf
COPY opcache.ini /etc/php7/conf.d/00_opcache.ini
COPY config.php /flarum/app/config.php
COPY extension /usr/local/bin/extension
COPY s6.d /etc/s6.d
COPY run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/*
VOLUME /flarum/app/assets /flarum/app/extensions VOLUME /flarum/app/assets /flarum/app/extensions
EXPOSE 8888 EXPOSE 8888
CMD ["run.sh"] CMD ["run.sh"]

View File

@ -9,7 +9,7 @@ Flarum is the next-generation forum software that makes online discussion fun. I
### Features ### Features
- Lightweight & secure image - Lightweight & secure image
- Based on Alpine Linux with **nginx** and **PHP 7.1** - Based on Alpine Linux with **nginx** and **PHP 7**
- Latest Flarum Beta (v0.1.0-beta.6) - Latest Flarum Beta (v0.1.0-beta.6)
- MySQL/Mariadb driver - MySQL/Mariadb driver
- OPCache extension configured - OPCache extension configured
@ -18,7 +18,7 @@ Flarum is the next-generation forum software that makes online discussion fun. I
- **VERSION** = Version of flarum (default: *v0.1.0-beta.6*) - **VERSION** = Version of flarum (default: *v0.1.0-beta.6*)
### Ports ### Ports
- **8888** - **8888**
@ -40,6 +40,8 @@ Flarum is the next-generation forum software that makes online discussion fun. I
| **DB_NAME** | MariaDB database name | *optional* | flarum | **DB_NAME** | MariaDB database name | *optional* | flarum
| **DB_PASS** | MariaDB database password | **required** | none | **DB_PASS** | MariaDB database password | **required** | none
| **DB_PREF** | Flarum tables prefix | *optional* | none | **DB_PREF** | Flarum tables prefix | *optional* | none
| **UPLOAD_MAX_SIZE** | The maximum size of an uploaded file | *optional* | 50M
| **MEMORY_LIMIT** | maximum amount of memory used by php | *optional* | 128M
## Installation ## Installation
@ -161,6 +163,8 @@ https://getcomposer.org/doc/03-cli.md#modifying-repositories
#### Installation #### Installation
:warning: **Admin password must contain at least 8 characters.**
![flarum-installation](http://i.imgur.com/e3Hscp4.png) ![flarum-installation](http://i.imgur.com/e3Hscp4.png)
#### Home page #### Home page

View File

@ -1,137 +0,0 @@
worker_processes auto;
pid /tmp/nginx.pid;
daemon off;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
error_log /tmp/ngx_error.log error;
sendfile on;
keepalive_timeout 15;
keepalive_disable msie6;
keepalive_requests 100;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
fastcgi_temp_path /tmp/fastcgi 1 2;
client_body_temp_path /tmp/client_body 1 2;
proxy_temp_path /tmp/proxy 1 2;
uwsgi_temp_path /tmp/uwsgi 1 2;
scgi_temp_path /tmp/scgi 1 2;
gzip on;
gzip_comp_level 5;
gzip_min_length 512;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_vary on;
gzip_disable "msie6";
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/vnd.ms-fontobject
font/truetype
font/opentype
image/svg+xml;
server {
listen 8888;
root /flarum/app;
index index.php;
charset utf-8;
client_max_body_size 50M;
fastcgi_buffers 64 4K;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 /500.html;
error_page 503 /503.html;
location = /403.html { root /flarum/app/vendor/flarum/core/error; }
location = /404.html { root /flarum/app/vendor/flarum/core/error; }
location = /500.html { root /flarum/app/vendor/flarum/core/error; }
location = /503.html { root /flarum/app/vendor/flarum/core/error; }
location / { try_files $uri $uri/ /index.php?$query_string; }
location /api { try_files $uri $uri/ /api.php?$query_string; }
location /admin { try_files $uri $uri/ /admin.php?$query_string; }
# Access path list
# --------------------------------------
location ~ /\. {
deny all;
return 404;
}
location ~* ^/(Procfile|storage|Vagrantfile|config\.php|LICENSE|vendor|flarum|scripts) {
deny all;
return 404;
}
location ~* composer(.*?) {
deny all;
return 404;
}
location ~* (.*?)\.md {
deny all;
return 404;
}
# Assets cache control
# --------------------------------------
location ~* \.(?:html|xml|json)$ {
expires -1;
}
location ~* \.(?:css|js)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~* \.(?:gif|jpe?g|png|ico|otf|eot|svg|ttf|woff|woff2)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# PHP Backend
# --------------------------------------
location ~* \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTP_PROXY "";
fastcgi_index index.php;
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
}
}
}

View File

@ -1,14 +0,0 @@
[global]
daemonize = no
[www]
listen = /tmp/php-fpm.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
php_admin_value[expose_php] = Off
php_admin_value[post_max_size] = 50M
php_admin_value[upload_max_filesize] = 50M

2
rootfs/etc/s6.d/php/run Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec php-fpm

View File

@ -0,0 +1,80 @@
server {
listen 8888;
root /flarum/app;
index index.php;
charset utf-8;
fastcgi_buffers 64 4K;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 /500.html;
error_page 503 /503.html;
location = /403.html { root /flarum/app/vendor/flarum/core/error; }
location = /404.html { root /flarum/app/vendor/flarum/core/error; }
location = /500.html { root /flarum/app/vendor/flarum/core/error; }
location = /503.html { root /flarum/app/vendor/flarum/core/error; }
location / { try_files $uri $uri/ /index.php?$query_string; }
location /api { try_files $uri $uri/ /api.php?$query_string; }
location /admin { try_files $uri $uri/ /admin.php?$query_string; }
# Access path list
# --------------------------------------
location ~ /\. {
deny all;
return 404;
}
location ~* ^/(Procfile|storage|Vagrantfile|config\.php|LICENSE|vendor|flarum|scripts) {
deny all;
return 404;
}
location ~* composer(.*?) {
deny all;
return 404;
}
location ~* (.*?)\.md {
deny all;
return 404;
}
# Assets cache control
# --------------------------------------
location ~* \.(?:html|xml|json)$ {
expires -1;
}
location ~* \.(?:css|js)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~* \.(?:gif|jpe?g|png|ico|otf|eot|svg|ttf|woff|woff2)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# PHP Backend
# --------------------------------------
location ~* \.php$ {
try_files $uri =404;
include /nginx/conf/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTP_PROXY "";
fastcgi_index index.php;
fastcgi_pass unix:/php/run/php-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
}
}

View File

@ -23,8 +23,11 @@ if [ -z "$FORUM_URL" ]; then
exit 1 exit 1
fi fi
sed -i -e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /nginx/conf/nginx.conf /php/etc/php-fpm.conf \
-e "s/<MEMORY_LIMIT>/$MEMORY_LIMIT/g" /php/etc/php-fpm.conf
# Set permissions # Set permissions
chown -R $UID:$GID /flarum /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d chown -R $UID:$GID /flarum /nginx /php /var/log /tmp /etc/s6.d
cd /flarum/app cd /flarum/app

View File

@ -1,2 +0,0 @@
#!/bin/sh
exec php-fpm7