1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Changed init systtems, php hangs in Docker container

This commit is contained in:
Dustin Wilson 2024-07-05 18:13:11 -05:00
parent 3901c92509
commit 5316ac628a
30 changed files with 111 additions and 72 deletions

View file

@ -1,24 +1,29 @@
#### Copy stage ####
FROM mensbeam/baseimage_alpine:latest as copy-stage
FROM mensbeam/baseimage_alpine:latest AS copy-stage
ARG VENDOR_DIR
RUN mkdir -p /copy/app/arsse
COPY dist/docker /copy
COPY arsse.php /copy/app/arsse/
COPY composer.json /copy/app/arsse/
COPY composer.lock /copy/app/arsse/
COPY www /copy/app/arsse/www
COPY lib /copy/app/arsse/lib
COPY ${VENDOR_DIR} /copy/app/arsse/vendor
COPY www /copy/app/arsse/www
RUN ln -s /config/arsse/config.php /copy/app/arsse/config.php
#### Runtime stage ####
FROM mensbeam/baseimage_alpine:latest
RUN apk add --no-cache \
composer \
gnu-libiconv \
libxml2 \
logrotate \
nginx \
php-fpm \
php83-dom \
php83-iconv \
php83-intl \
php83-mysqli \
php83-pcntl \
@ -27,7 +32,9 @@ RUN apk add --no-cache \
php83-pdo_sqlite \
php83-pgsql \
php83-posix \
php83-sqlite3
php83-sqlite3 && \
sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf && \
sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' /etc/periodic/daily/logrotate
COPY --from=copy-stage /copy/ /

View file

@ -13,5 +13,5 @@ fastcgi_param QUERY_STRING $query_string;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/var/run/php/arsse.sock;
fastcgi_pass unix:/app/arsse/arsse.sock;
fastcgi_param SCRIPT_FILENAME /app/arsse/arsse.php;

View file

@ -1,22 +1,10 @@
server {
server_name -;
server_name ~^.*$;
listen 80;
listen [::]:80;
#include /config/nginx/ssl.conf;
# Automatic HTTPS redirection
uninitialized_variable_warn off;
if ($https = "on") {
set $tls_redir off;
}
if ($tls_redir = "") {
set $tls_redir on;
}
if ($tls_redir = "on") {
rewrite ^ https://$host$request_uri;
}
root /app/arsse/www;
location @arsse {

View file

@ -131,19 +131,6 @@ http {
# Sets the path, format, and configuration for a buffered log write.
access_log /config/log/nginx/access.log;
# Additional configs.
#include /config/nginx/http.d/*.conf;
# Fallback virtual server
server {
server_name ~^.*$;
listen 80;
location / {
return 503;
}
}
# Includes virtual hosts configs.
include /config/nginx/hosts.conf;
}

View file

@ -19,3 +19,15 @@ ssl_prefer_server_ciphers on;
ssl_certificate /config/keys/fullchain.cer;
ssl_certificate_key /config/keys/cert.key;
ssl_trusted_certificate /config/keys/cert.cer;
# Automatic HTTPS redirection
uninitialized_variable_warn off;
if ($https = "on") {
set $tls_redir off;
}
if ($tls_redir = "") {
set $tls_redir on;
}
if ($tls_redir = "on") {
rewrite ^ https://$host$request_uri;
}

14
dist/docker/etc/logrotate.d/nginx vendored Normal file
View file

@ -0,0 +1,14 @@
/config/log/nginx/*.log {
weekly
rotate 7
compress
delaycompress
nodateext
notifempty
missingok
sharedscripts
postrotate
sv hup /etc/service/nginx
endscript
su ook ook
}

14
dist/docker/etc/logrotate.d/php-fpm vendored Normal file
View file

@ -0,0 +1,14 @@
/config/log/php/*.log {
rotate 5
weekly
missingok
notifempty
delaycompress
compress
nodateext
sharedscripts
postrotate
sv hup /etc/service/php-fpm
endscript
su ook ook
}

View file

@ -1,10 +1,8 @@
[global]
env[PATH] = /usr/local/bin:/usr/bin:/bin
error_log = /config/log/php/error.log
[arsse]
user = ook
group = ook
listen = /var/run/php/arsse.sock
listen = /app/arsse/arsse.sock
listen.owner = ook
listen.group = ook
pm = dynamic

View file

@ -1,22 +1,22 @@
#!/usr/bin/env bash
while ! grep -qF "init-user: done"; do
sleep 1
done
logger -t 'init-config' "start" >> /var/log/run-log
#!/usr/bin/with-contenv bash
if [ ! -d "/config/arsse" ] || [ ! "$(ls -A "/config/arsse")" ]; then
echo -n "[init-config] Copying defaults to /config/arsse..."
cp -R /default/arsse/. /config/arsse
chown -R ook:ook /config/arsse
echo " done"
fi
if [ ! -d "/config/nginx" ] || [ ! "$(ls -A "/config/nginx")" ]; then
echo -n "[init-config] Copying defaults to /config/nginx..."
cp -R /default/nginx/. /config/nginx
chown -R ook:ook /config/nginx
echo " done"
fi
if [ ! -d "/config/log" ] || [ ! "$(ls -A "/config/log")" ]; then
echo -n "[init-config] Creating log folder at /config/log..."
mkdir -p /config/log/php
mkdir -p /config/log/nginx
echo " done"
fi
logger -t 'init-config' "done" >> /var/log/run-log
echo -n "[init-config] Setting permissions for ook user..."
chown -R ook:ook /app /config /default 2>/dev/null
echo " done"

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-config/run

View file

@ -0,0 +1,34 @@
#!/usr/bin/with-contenv bash
touch /config/log/nginx/access.log
touch /config/log/nginx/error.log
# Download dhparams if necessary
if [ ! -f /config/nginx/dhparams.pem ]; then
curl -o /config/nginx/dhparams.pem -L "https://ssl-config.mozilla.org/ffdhe4096.txt"
fi
# Set resolver
touch /config/nginx/resolver.conf
if ! grep -q 'resolver' /config/nginx/resolver.conf; then
RESOLVERRAW=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf)
for i in ${RESOLVERRAW}; do
if [[ "$(awk -F ':' '{print NF-1}' <<< "${i}")" -le 2 ]]; then
RESOLVER="${RESOLVER} ${i}"
fi
done
if [[ -z "${RESOLVER}" ]]; then
RESOLVER="127.0.0.11"
fi
echo "Setting resolver to ${RESOLVER}"
RESOLVEROUTPUT="# This file is auto-generated only on first start, based on the container's /etc/resolv.conf file. Feel free to modify it as you wish.\n\nresolver ${RESOLVER} valid=30s;"
echo -e "${RESOLVEROUTPUT}" > /config/nginx/resolver.conf
fi
# Set worker_processes
touch /config/nginx/worker_processes.conf
if ! grep -q 'worker_processes' /config/nginx/worker_processes.conf; then
WORKER_PROCESSES=$(nproc)
echo "Setting worker_processes to ${WORKER_PROCESSES}"
echo -e "# This file is auto-generated only on first start, based on the cpu cores detected. Feel free to change it to any other number or to auto to let nginx handle it automatically.\n\nworker_processes ${WORKER_PROCESSES};" >/config/nginx/worker_processes.conf
fi

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-nginx/run

View file

@ -0,0 +1,2 @@
#!/usr/bin/with-contenv bash
exec nginx -c /config/nginx/nginx.conf

View file

@ -0,0 +1 @@
longrun

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/nginx/run

View file

@ -0,0 +1,2 @@
#!/usr/bin/with-contenv bash
su-exec ook /usr/sbin/php-fpm83 -F

View file

@ -0,0 +1 @@
longrun

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/php-fpm/run

View file

@ -1,16 +0,0 @@
#!/usr/bin/env bash
while ! grep -qF "init-config: done"; do
sleep 1
done
logger -t 'init-arsse' "start" >> /var/log/run-log
chown -R ook:ook /app
if [ ! -d '/app/arsse/vendor' ]; then
cd /app/arsse
composer install
fi
logger -t 'init-arsse' "done" >> /var/log/run-log

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
while ! grep -qF "init-arsse: done"; do
sleep 1
done
logger -t 'nginx' "start" >> /var/log/run-log
nginx -c /config/nginx/nginx.conf -g 'daemon off;'
logger -t 'nginx' "done" >> /var/log/run-log