embed nginx into rainloop image

main
Ricard Illa 2022-08-16 18:01:04 +02:00
parent 413711a3a8
commit 981ae49aa0
No known key found for this signature in database
GPG Key ID: F69A672B72E54902
4 changed files with 80 additions and 27 deletions

View File

@ -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"]

View File

@ -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) \

7
rainloop/entrypoint.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
echo "starting daemonized nginx"
nginx
echo "starting php-fpm"
php-fpm

51
rainloop/nginx.conf Normal file
View File

@ -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