diff --git a/.gitignore b/.gitignore index 6aa30c5..5cf142b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ u/* -active-users.txt version.txt secret.php diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c9fd820 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM base/archlinux:latest +MAINTAINER Kai Hendry +RUN pacman -Syu --noconfirm nginx php php-fpm supervisor git + +# /srv/http used to match with Archlinux's php.ini open_basedir default +RUN git clone https://github.com/kaihendry/greptweet.git /srv/http +WORKDIR /srv/http +RUN git describe --always > version.txt + +ADD nginx.conf /etc/nginx/nginx.conf +ADD php-fpm.ini /etc/supervisor.d/php-fpm.ini +ADD nginx.ini /etc/supervisor.d/nginx.ini +ADD secret.php /srv/http/secret.php + +RUN chown -R http:http /srv/http + +VOLUME /srv/http/u/ + +EXPOSE 80 + +# We use supervisord to keep the two processes we need going +CMD supervisord -n -c /etc/supervisord.conf + +# sudo docker run -v /srv/www/greptweet.com:/srv/http/u -p 80:80 -t -i greptweet diff --git a/nginx.conf b/nginx.conf index 00598f4..8b3087e 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,18 +1,20 @@ -# sudo systemctl start php-fpm -# sudo systemctl start nginx -# Tested with Nginx 1.6 on Archlinux +daemon off; +worker_processes 1; events { worker_connections 1024; } http { - include mime.types; - sendfile on; + include mime.types; + sendfile on; + gzip on; + gzip_vary on; + gzip_types application/x-javascript text/css application/javascript text/html application/json; server { - server_name greptweet; - root /srv/www/greptweet; + server_name greptweet.com; + root /srv/http; charset utf-8; access_log /var/log/nginx/greptweet.access.log; error_log /var/log/nginx/greptweet.error.log; @@ -22,11 +24,15 @@ http { rewrite ^/f/(.*)$ /create.php?id=$1 last; } - location ~ \.txt$ { + location ~ \.(svg|txt)$ { gzip_static always; gunzip on; } + location ~* \.(svg|css|woff|js)$ { + expires 7d; + } + location ~ \.php$ { try_files $uri = 404; fastcgi_pass unix:/run/php-fpm/php-fpm.sock; diff --git a/nginx.ini b/nginx.ini new file mode 100644 index 0000000..04ff8ce --- /dev/null +++ b/nginx.ini @@ -0,0 +1,2 @@ +[program:nginx] +command=/usr/bin/nginx -c /etc/nginx/nginx.conf diff --git a/php-fpm.ini b/php-fpm.ini new file mode 100644 index 0000000..f218c3b --- /dev/null +++ b/php-fpm.ini @@ -0,0 +1,2 @@ +[program:php-fpm] +command=/usr/bin/php-fpm -F