From ee027268e6aee2423e6d60260b2403798972cabf Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Sun, 27 Aug 2023 15:21:51 +0200 Subject: [PATCH] feat: added rompr --- rompr/Dockerfile | 95 ++++++++++++++++++++++++++++++++++++++ rompr/Makefile | 19 ++++++++ rompr/nginx.conf | 51 ++++++++++++++++++++ rompr/services.d/nginx/run | 3 ++ 4 files changed, 168 insertions(+) create mode 100644 rompr/Dockerfile create mode 100644 rompr/Makefile create mode 100644 rompr/nginx.conf create mode 100755 rompr/services.d/nginx/run diff --git a/rompr/Dockerfile b/rompr/Dockerfile new file mode 100644 index 0000000..aaf9c5a --- /dev/null +++ b/rompr/Dockerfile @@ -0,0 +1,95 @@ +FROM php:7.2-fpm-alpine + +ARG ROMPR_VERSION=2.06 + +ARG S6_OVERLAY_VERSION=3.1.5.0 +ARG ARCH=aarch64 + + +# init ######################################################################## + +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${ARCH}.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \ + tar -C / -Jxpf /tmp/s6-overlay-${ARCH}.tar.xz && \ + rm /tmp/s6-overlay-noarch.tar.xz \ + /tmp/s6-overlay-${ARCH}.tar.xz + +COPY services.d /etc/services.d + +ENTRYPOINT ["/init"] + + +# php ######################################################################### + +RUN apk add curl-dev libpng-dev icu-dev sqlite-dev && \ + docker-php-ext-install curl gd intl pdo_sqlite && \ + apk del curl-dev libpng-dev icu-dev sqlite-dev && \ + apk add curl libpng icu sqlite + +# according to https://fatg3erman.github.io/RompR/Recommended-Installation-on-Linux +# we want: +# +# allow_url_fopen = On +# memory_limit = 128M +# max_execution_time = 1800 +# post_max_size = 256M +# upload_max_filesize = 10M +# max_file_uploads = 200 +# +# as well as +# +# extension=curl +# extension=pdo_sqlite +# extension=gd +# extension=intl + +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ + sed -i 's/^\(allow_url_fopen =\).*$/\1 On/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/^\(memory_limit =\).*$/\1 128M/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/^\(max_execution_time =\).*$/\1 1800/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/^\(post_max_size =\).*$/\1 256M/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/^\(upload_max_filesize =\).*$/\1 10M/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/^\(max_file_uploads =\).*$/\1 200/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/;\(extension=curl\)/\1/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/;\(extension=pdo_sqlite\)/\1/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/;\(extension=gd\).*$/\1/' "$PHP_INI_DIR/php.ini" && \ + sed -i 's/;\(extension=intl\)/\1/' "$PHP_INI_DIR/php.ini" && \ + echo "user=rompr" >> /usr/local/etc/php-fpm.conf + +CMD php-fpm + + +# nginx ####################################################################### + +RUN apk add --no-cache nginx +COPY nginx.conf /etc/nginx/nginx.conf + + +# rompr ####################################################################### + +RUN addgroup \ + --gid 10001 \ + rompr && \ + adduser \ + --uid 10000 \ + --home /var/www/rompr \ + --ingroup rompr \ + --disabled-password \ + --shell /sbin/nologin \ + rompr + +RUN mkdir -p /var/www +ADD https://github.com/fatg3erman/RompR/releases/download/${ROMPR_VERSION}/rompr-${ROMPR_VERSION}.zip /var/www +RUN unzip "/var/www/rompr-$ROMPR_VERSION.zip" -d /var/www && \ + rm "/var/www/rompr-$ROMPR_VERSION.zip" && \ + mkdir -p /var/www/rompr/albumart /var/www/rompr/prefs && \ + mkdir -p /run/nginx /var/run && \ + touch /var/run/nginx.pid && \ + chown -R rompr:rompr /var/www/rompr + +WORKDIR /var/www/rompr + +############################################################################### + + diff --git a/rompr/Makefile b/rompr/Makefile new file mode 100644 index 0000000..5221a6e --- /dev/null +++ b/rompr/Makefile @@ -0,0 +1,19 @@ +IMG_NAME=rompr +REGISTRY=registry.monotremata.xyz +IMG=$(REGISTRY)/$(IMG_NAME) +PLATFORMS=linux/arm64 + +.PHONY: build push buildx + +build: Dockerfile nginx.conf services.d/nginx/run + docker build -t $(IMG) . + +push: build + docker image push $(IMG) + +buildx: Dockerfile nginx.conf services.d/nginx/run + docker buildx build \ + --platform $(PLATFORMS) \ + --tag $(IMG) \ + --push \ + . diff --git a/rompr/nginx.conf b/rompr/nginx.conf new file mode 100644 index 0000000..7bfa1fb --- /dev/null +++ b/rompr/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; + listen [::]:80; + + root /var/www/rompr; + index index.php index.html index.htm; + + client_max_body_size 256M; + + location / { + allow all; + index index.php; + + location ~ \.php { + try_files $uri index.php =404; + + fastcgi_pass 127.0.0.1:9000; + + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $request_filename; + include /etc/nginx/fastcgi_params; + fastcgi_read_timeout 1800; + } + error_page 404 = /rompr/404.php; + try_files $uri $uri/ =404; + location ~ /albumart/* { + expires -1s; + } + } + } +} + +# vi: ft=nginx.conf diff --git a/rompr/services.d/nginx/run b/rompr/services.d/nginx/run new file mode 100755 index 0000000..0d024bd --- /dev/null +++ b/rompr/services.d/nginx/run @@ -0,0 +1,3 @@ +#!/command/execlineb -P + +nginx -g "daemon off";