Describe how greptweet is run in a Dockerfile

This commit is contained in:
EC2 Default User
2014-10-15 10:35:01 +00:00
parent ab8aa55edd
commit 9393107859
5 changed files with 42 additions and 9 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
u/* u/*
active-users.txt
version.txt version.txt
secret.php secret.php

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM base/archlinux:latest
MAINTAINER Kai Hendry <hendry@iki.fi>
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

View File

@@ -1,6 +1,5 @@
# sudo systemctl start php-fpm daemon off;
# sudo systemctl start nginx worker_processes 1;
# Tested with Nginx 1.6 on Archlinux
events { events {
worker_connections 1024; worker_connections 1024;
@@ -9,10 +8,13 @@ events {
http { http {
include mime.types; include mime.types;
sendfile on; sendfile on;
gzip on;
gzip_vary on;
gzip_types application/x-javascript text/css application/javascript text/html application/json;
server { server {
server_name greptweet; server_name greptweet.com;
root /srv/www/greptweet; root /srv/http;
charset utf-8; charset utf-8;
access_log /var/log/nginx/greptweet.access.log; access_log /var/log/nginx/greptweet.access.log;
error_log /var/log/nginx/greptweet.error.log; error_log /var/log/nginx/greptweet.error.log;
@@ -22,11 +24,15 @@ http {
rewrite ^/f/(.*)$ /create.php?id=$1 last; rewrite ^/f/(.*)$ /create.php?id=$1 last;
} }
location ~ \.txt$ { location ~ \.(svg|txt)$ {
gzip_static always; gzip_static always;
gunzip on; gunzip on;
} }
location ~* \.(svg|css|woff|js)$ {
expires 7d;
}
location ~ \.php$ { location ~ \.php$ {
try_files $uri = 404; try_files $uri = 404;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock; fastcgi_pass unix:/run/php-fpm/php-fpm.sock;

2
nginx.ini Normal file
View File

@@ -0,0 +1,2 @@
[program:nginx]
command=/usr/bin/nginx -c /etc/nginx/nginx.conf

2
php-fpm.ini Normal file
View File

@@ -0,0 +1,2 @@
[program:php-fpm]
command=/usr/bin/php-fpm -F