diff --git a/rainloop/Dockerfile b/rainloop/Dockerfile index 733aa60..48a6dc9 100644 --- a/rainloop/Dockerfile +++ b/rainloop/Dockerfile @@ -1,20 +1,8 @@ -FROM alpine:3.16 +FROM php:7.4-fpm-alpine -RUN apk add --no-cache \ - nginx \ - curl \ - php7-fpm \ - php7 \ - php7-curl \ - php7-iconv \ - php7-json \ - php7-openssl \ - php7-dom && \ - mkdir -p /var/www/rainloop && \ - cd /var/www/rainloop && \ - curl -sL https://repository.rainloop.net/installer.php | php && \ - sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf && \ - addgroup \ +RUN apk add --no-cache nginx + +RUN addgroup \ --gid 10001 \ rainloop && \ adduser \ @@ -23,16 +11,23 @@ RUN apk add --no-cache \ --ingroup rainloop \ --disabled-password \ --shell /sbin/nologin \ - rainloop && \ + rainloop + +RUN mkdir -p /var/www/rainloop && \ + cd /var/www/rainloop && \ + curl -sL https://repository.rainloop.net/installer.php | php && \ mkdir -p /run/nginx /var/run && \ touch /var/run/nginx.pid && \ - chown -R rainloop:rainloop \ - /var/www/rainloop \ - /var/log/php7 \ - /var/lib/nginx \ - /var/log/nginx \ - /run/nginx \ - /var/run/nginx.pid + chown -R rainloop:rainloop /var/www/rainloop + +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + echo "user=rainloop" >> /usr/local/etc/php-fpm.conf + +COPY nginx.conf /etc/nginx/nginx.conf + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh -USER rainloop WORKDIR /var/www/rainloop + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/rainloop/Makefile b/rainloop/Makefile index a9f873f..5d1ab8d 100644 --- a/rainloop/Makefile +++ b/rainloop/Makefile @@ -5,13 +5,13 @@ PLATFORMS=linux/arm64 .PHONY: build push buildx -build: Dockerfile +build: Dockerfile entrypoint.sh nginx.conf docker build -t $(IMG) . push: build docker image push $(IMG) -buildx: Dockerfile +buildx: Dockerfile entrypoint.sh nginx.conf docker buildx build \ --platform $(PLATFORMS) \ --tag $(IMG) \ diff --git a/rainloop/entrypoint.sh b/rainloop/entrypoint.sh new file mode 100644 index 0000000..c422f82 --- /dev/null +++ b/rainloop/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +echo "starting daemonized nginx" +nginx + +echo "starting php-fpm" +php-fpm diff --git a/rainloop/nginx.conf b/rainloop/nginx.conf new file mode 100644 index 0000000..80ebe32 --- /dev/null +++ b/rainloop/nginx.conf @@ -0,0 +1,51 @@ +worker_processes auto; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + error_log /dev/stdout info; + error_log /dev/stderr warn; + + sendfile on; + + index index.php; + + server { + listen 80; + root /var/www/rainloop; + + location ^~ /data { + deny all; + } + + location ~ \.php$ { + # regex to split $uri to $fastcgi_script_name and $fastcgi_path + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + + # Check that the PHP script exists before passing it + # try_files $fastcgi_script_name =404; + + # Bypass the fact that try_files resets $fastcgi_path_info + # see: http://trac.nginx.org/nginx/ticket/321 + set $path_info $fastcgi_path_info; + fastcgi_param PATH_INFO $path_info; + + fastcgi_index index.php; + include fastcgi.conf; + + fastcgi_pass 127.0.0.1:9000; + } + + location / { + try_files $uri $uri/ =404; + } + } +} + +# vi: ft=nginx.conf