Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine Linux 3.17 #195

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 44 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# syntax=docker/dockerfile:1

ARG ALPINE_S6_TAG=3.15-2.2.0.3

ARG LIBSIG_VERSION=3.0.3
ARG CARES_VERSION=1.17.2
ARG CURL_VERSION=7.78.0
ARG XMLRPC_VERSION=01.58.00
ARG XMLRPC_VERSION=v1.58.0
ARG LIBTORRENT_VERSION=v0.13.8
ARG RTORRENT_VERSION=v0.9.8
ARG MKTORRENT_VERSION=v1.1

ARG NGINX_VERSION=1.21.1
ARG NGINX_VERSION=1.22.1
ARG NGINX_DAV_VERSION=v3.0.0
ARG NGINX_UID=102
ARG NGINX_GID=102
ARG GEOIP2_PHPEXT_VERSION=1.1.1
ARG GEOIP2_PHPEXT_VERSION=1.3.1

# 3.10
ARG RUTORRENT_VERSION=954479ffd00eb58ad14f9a667b3b9b1e108e80a2
ARG GEOIP2_RUTORRENT_VERSION=9f7b59e29bc472eec8c3943d7646bf9462577b16

FROM --platform=$BUILDPLATFORM alpine AS src
ARG ALPINE_VERSION=3.17
ARG ALPINE_S6_VERSION=${ALPINE_VERSION}-2.2.0.3

FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS src
RUN apk --update --no-cache add curl git subversion tar tree xz
WORKDIR /src

Expand All @@ -34,7 +35,10 @@ RUN curl -sSL "https://c-ares.haxx.se/download/c-ares-${CARES_VERSION}.tar.gz" |

FROM src AS src-xmlrpc
ARG XMLRPC_VERSION
RUN svn checkout "http://svn.code.sf.net/p/xmlrpc-c/code/release_number/${XMLRPC_VERSION}/" .
RUN <<EOT
git clone /~https://github.com/crazy-max/xmlrpc-c.git .
git reset --hard $XMLRPC_VERSION
EOT

FROM src AS src-curl
ARG CURL_VERSION
Expand Down Expand Up @@ -73,7 +77,10 @@ EOT

FROM src AS src-geoip2-phpext
ARG GEOIP2_PHPEXT_VERSION
RUN curl -SsL "https://pecl.php.net/get/geoip-${GEOIP2_PHPEXT_VERSION}.tgz" -o "geoip.tgz"
RUN <<EOT
git clone /~https://github.com/rlerdorf/geoip.git .
git reset --hard $GEOIP2_PHPEXT_VERSION
EOT

FROM src AS src-rutorrent
ARG RUTORRENT_VERSION
Expand All @@ -95,7 +102,7 @@ FROM src AS src-mmdb
RUN curl -SsOL "/~https://github.com/crazy-max/geoip-updater/raw/mmdb/GeoLite2-City.mmdb" \
&& curl -SsOL "/~https://github.com/crazy-max/geoip-updater/raw/mmdb/GeoLite2-Country.mmdb"

FROM crazymax/alpine-s6:${ALPINE_S6_TAG} AS builder
FROM crazymax/alpine-s6:${ALPINE_S6_VERSION} AS builder
RUN apk --update --no-cache add \
autoconf \
automake \
Expand All @@ -112,8 +119,8 @@ RUN apk --update --no-cache add \
nghttp2-dev \
openssl-dev \
pcre-dev \
php7-dev \
php7-pear \
php81-dev \
php81-pear \
tar \
tree \
xz \
Expand Down Expand Up @@ -239,12 +246,18 @@ RUN tree ${DIST_PATH}

WORKDIR /usr/local/src/geoip2-phpext
COPY --from=src-geoip2-phpext /src .
RUN pecl install geoip.tgz
RUN mkdir -p ${DIST_PATH}/usr/lib/php7/modules
RUN cp -f /usr/lib/php7/modules/geoip.so ${DIST_PATH}/usr/lib/php7/modules/
RUN <<EOT
set -e
phpize81
./configure
make
make install
EOT
RUN mkdir -p ${DIST_PATH}/usr/lib/php81/modules
RUN cp -f /usr/lib/php81/modules/geoip.so ${DIST_PATH}/usr/lib/php81/modules/
RUN tree ${DIST_PATH}

FROM crazymax/alpine-s6:${ALPINE_S6_TAG}
FROM crazymax/alpine-s6:${ALPINE_S6_VERSION}
COPY --from=builder /dist /
COPY --from=src-rutorrent --chown=nobody:nogroup /src /var/www/rutorrent
COPY --from=src-geoip2-rutorrent --chown=nobody:nogroup /src /var/www/rutorrent/plugins/geoip2
Expand Down Expand Up @@ -281,22 +294,22 @@ RUN apk --update --no-cache add \
ncurses \
openssl \
pcre \
php7 \
php7-bcmath \
php7-cli \
php7-ctype \
php7-curl \
php7-fpm \
php7-json \
php7-mbstring \
php7-openssl \
php7-phar \
php7-posix \
php7-session \
php7-sockets \
php7-xml \
php7-zip \
php7-zlib \
php81 \
php81-bcmath \
php81-cli \
php81-ctype \
php81-curl \
php81-fpm \
php81-json \
php81-mbstring \
php81-openssl \
php81-phar \
php81-posix \
php81-session \
php81-sockets \
php81-xml \
php81-zip \
php81-zlib \
python3 \
py3-pip \
shadow \
Expand Down
6 changes: 3 additions & 3 deletions rootfs/etc/cont-init.d/02-fix-perms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ mkdir -p /data/rtorrent \
/var/run/nginx \
/var/run/php-fpm \
/var/run/rtorrent
chown rtorrent. \
chown rtorrent:rtorrent \
/data \
/data/rtorrent \
/data/rutorrent \
/downloads
chown -R rtorrent. \
chown -R rtorrent:rtorrent \
/etc/rtorrent \
/passwd \
/tpls \
/var/cache/nginx \
/var/lib/nginx \
/var/log/php7 \
/var/log/php81 \
/var/run/nginx \
/var/run/php-fpm \
/var/run/rtorrent
34 changes: 17 additions & 17 deletions rootfs/etc/cont-init.d/03-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ echo "Setting PHP-FPM configuration..."
sed -e "s/@MEMORY_LIMIT@/$MEMORY_LIMIT/g" \
-e "s/@UPLOAD_MAX_SIZE@/$UPLOAD_MAX_SIZE/g" \
-e "s/@CLEAR_ENV@/$CLEAR_ENV/g" \
/tpls/etc/php7/php-fpm.d/www.conf > /etc/php7/php-fpm.d/www.conf
/tpls/etc/php81/php-fpm.d/www.conf > /etc/php81/php-fpm.d/www.conf

echo "Setting PHP INI configuration..."
sed -i "s|memory_limit.*|memory_limit = ${MEMORY_LIMIT}|g" /etc/php7/php.ini
sed -i "s|;date\.timezone.*|date\.timezone = ${TZ}|g" /etc/php7/php.ini
sed -i "s|max_file_uploads.*|max_file_uploads = ${MAX_FILE_UPLOADS}|g" /etc/php7/php.ini
sed -i "s|memory_limit.*|memory_limit = ${MEMORY_LIMIT}|g" /etc/php81/php.ini
sed -i "s|;date\.timezone.*|date\.timezone = ${TZ}|g" /etc/php81/php.ini
sed -i "s|max_file_uploads.*|max_file_uploads = ${MAX_FILE_UPLOADS}|g" /etc/php81/php.ini

# OpCache
echo "Setting OpCache configuration..."
sed -e "s/@OPCACHE_MEM_SIZE@/$OPCACHE_MEM_SIZE/g" \
/tpls/etc/php7/conf.d/opcache.ini > /etc/php7/conf.d/opcache.ini
/tpls/etc/php81/conf.d/opcache.ini > /etc/php81/conf.d/opcache.ini

# Nginx
echo "Setting Nginx configuration..."
Expand Down Expand Up @@ -192,7 +192,7 @@ if [ ! -f /data/rtorrent/.rtorrent.rc ]; then
echo " Creating default configuration..."
cp /tpls/.rtorrent.rc /data/rtorrent/.rtorrent.rc
fi
chown rtorrent. /data/rtorrent/.rtorrent.rc
chown rtorrent:rtorrent /data/rtorrent/.rtorrent.rc

# ruTorrent config
echo "Bootstrapping ruTorrent configuration..."
Expand Down Expand Up @@ -263,7 +263,7 @@ cat > /var/www/rutorrent/conf/config.php <<EOL

\$locale = '${RU_LOCALE}';
EOL
chown nobody.nogroup "/var/www/rutorrent/conf/config.php"
chown nobody:nogroup "/var/www/rutorrent/conf/config.php"

# Symlinking ruTorrent config
ln -sf /data/rutorrent/conf/users /var/www/rutorrent/conf/users
Expand All @@ -272,13 +272,13 @@ if [ ! -f /data/rutorrent/conf/access.ini ]; then
mv /var/www/rutorrent/conf/access.ini /data/rutorrent/conf/access.ini
ln -sf /data/rutorrent/conf/access.ini /var/www/rutorrent/conf/access.ini
fi
chown rtorrent. /data/rutorrent/conf/access.ini
chown rtorrent:rtorrent /data/rutorrent/conf/access.ini
if [ ! -f /data/rutorrent/conf/plugins.ini ]; then
echo "Symlinking ruTorrent plugins.ini file..."
mv /var/www/rutorrent/conf/plugins.ini /data/rutorrent/conf/plugins.ini
ln -sf /data/rutorrent/conf/plugins.ini /var/www/rutorrent/conf/plugins.ini
fi
chown rtorrent. /data/rutorrent/conf/plugins.ini
chown rtorrent:rtorrent /data/rutorrent/conf/plugins.ini

# Remove ruTorrent core plugins
if [ -n "$RU_REMOVE_CORE_PLUGINS" ]; then
Expand All @@ -300,13 +300,13 @@ if [ -d "/var/www/rutorrent/plugins/create" ]; then
\$pathToCreatetorrent = '/usr/local/bin/mktorrent';
\$recentTrackersMaxCount = 15;
EOL
chown nobody.nogroup "/var/www/rutorrent/plugins/create/conf.php"
chown nobody:nogroup "/var/www/rutorrent/plugins/create/conf.php"
else
echo " WARNING: create plugin does not exist"
fi

echo "Checking ruTorrent custom plugins..."
plugins=$(ls -l /data/rutorrent/plugins | egrep '^d' | awk '{print $9}')
plugins=$(ls -l /data/rutorrent/plugins | grep -E '^d' | awk '{print $9}')
for plugin in ${plugins}; do
if [ "${plugin}" == "theme" ]; then
echo " WARNING: theme plugin cannot be overriden"
Expand All @@ -317,7 +317,7 @@ for plugin in ${plugins}; do
rm -rf "/var/www/rutorrent/plugins/${plugin}"
fi
cp -Rf "/data/rutorrent/plugins/${plugin}" "/var/www/rutorrent/plugins/${plugin}"
chown -R nobody.nogroup "/var/www/rutorrent/plugins/${plugin}"
chown -R nobody:nogroup "/var/www/rutorrent/plugins/${plugin}"
done

echo "Checking ruTorrent plugins configuration..."
Expand All @@ -337,18 +337,18 @@ for pluginConfFile in /data/rutorrent/plugins-conf/*.php; do
fi
echo " Copying ${pluginName} plugin config..."
cp -f "${pluginConfFile}" "/var/www/rutorrent/plugins/${pluginName}/conf.php"
chown nobody.nogroup "/var/www/rutorrent/plugins/${pluginName}/conf.php"
chown nobody:nogroup "/var/www/rutorrent/plugins/${pluginName}/conf.php"
done

echo "Checking ruTorrent custom themes..."
themes=$(ls -l /data/rutorrent/themes | egrep '^d' | awk '{print $9}')
themes=$(ls -l /data/rutorrent/themes | grep -E '^d' | awk '{print $9}')
for theme in ${themes}; do
echo " Copying custom ${theme} theme..."
if [ -d "/var/www/rutorrent/plugins/theme/themes/${theme}" ]; then
rm -rf "/var/www/rutorrent/plugins/theme/themes/${theme}"
fi
cp -Rf "/data/rutorrent/themes/${theme}" "/var/www/rutorrent/plugins/theme/themes/${theme}"
chown -R nobody.nogroup "/var/www/rutorrent/plugins/theme/themes/${theme}"
chown -R nobody:nogroup "/var/www/rutorrent/plugins/theme/themes/${theme}"
done

echo "Setting GeoIP2 databases for geoip2 plugin..."
Expand All @@ -364,14 +364,14 @@ else
fi

echo "Fixing perms..."
chown rtorrent. \
chown rtorrent:rtorrent \
/data/rutorrent/share/users \
/data/rutorrent/share/torrents \
/downloads \
/downloads/complete \
/downloads/temp \
"${RU_LOG_FILE}"
chown -R rtorrent. \
chown -R rtorrent:rtorrent \
/data/geoip \
/data/rtorrent/log \
/data/rtorrent/.session \
Expand Down
2 changes: 1 addition & 1 deletion rootfs/etc/cont-init.d/04-create-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cat > /etc/services.d/php-fpm/run <<EOL
#!/usr/bin/execlineb -P
with-contenv
s6-setuidgid ${PUID}:${PGID}
php-fpm7 -F
php-fpm81 -F
EOL
chmod +x /etc/services.d/php-fpm/run

Expand Down
2 changes: 1 addition & 1 deletion rootfs/tpls/.rtorrent.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ method.insert = d.move_to_complete, simple, "d.directory.set=$argument.1=; execu
method.set_key = event.download.finished,move_complete,"d.move_to_complete=$d.data_path=,$d.get_finished_dir="

# Erase data when torrent deleted (no need erasedata plugin on ruTorrent)
method.set_key = event.download.erased,delete_erased,"execute=rm,-rf,--,$d.data_path="
method.set_key = event.download.erased,delete_erased,"execute=rm,-rf,--,$d.data_path="
2 changes: 1 addition & 1 deletion rootfs/tpls/etc/nginx/conf.d/rpc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ server {
include /etc/nginx/scgi_params;
scgi_pass unix:/var/run/rtorrent/scgi.socket;
}
}
}
4 changes: 2 additions & 2 deletions rootfs/tpls/etc/nginx/conf.d/rutorrent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ server {
fastcgi_buffers 256 4k;
fastcgi_intercept_errors on;
fastcgi_read_timeout 14400;
fastcgi_pass unix:/var/run/php-fpm/php-fpm7.sock;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SERVER_SOFTWARE "";
}

Expand All @@ -53,7 +53,7 @@ server {
location ~ ^/(status|ping)$ {
allow 127.0.0.1;
deny all;
fastcgi_pass unix:/var/run/php-fpm/php-fpm7.sock;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
include fastcgi_params;
fastcgi_param SERVER_SOFTWARE "";
Expand Down
2 changes: 1 addition & 1 deletion rootfs/tpls/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ http {
auth_delay @AUTH_DELAY@;

include /etc/nginx/conf.d/*.conf;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ opcache.fast_shutdown=1
opcache.memory_consumption=@OPCACHE_MEM_SIZE@
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.revalidate_freq=60
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[global]
pid = /var/run/php-fpm/php-fpm7.pid
pid = /var/run/php-fpm/php-fpm.pid
daemonize = no
error_log = /proc/self/fd/2

[www]
listen = /var/run/php-fpm/php-fpm7.sock
listen = /var/run/php-fpm/php-fpm.sock
access.log = /dev/null

pm = dynamic
Expand All @@ -28,4 +28,4 @@ php_admin_value[upload_max_filesize] = @UPLOAD_MAX_SIZE@
php_admin_value[max_execution_time] = 10800
php_admin_value[max_input_time] = 3600
php_admin_value[expose_php] = Off
php_admin_value[memory_limit] = @MEMORY_LIMIT@
php_admin_value[memory_limit] = @MEMORY_LIMIT@