diff --git a/Dockerfile b/Dockerfile index 18529a1..e075c49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.12 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.15 # set version label ARG BUILD_DATE @@ -8,55 +8,54 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="chbmb" RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --upgrade --virtual=build-dependencies \ - curl \ - tar && \ - echo "**** install runtime packages ****" && \ - apk add --no-cache --upgrade \ - php7-ctype \ - php7-dom \ - php7-gd \ - php7-intl \ - php7-mbstring \ - php7-opcache \ - php7-openssl \ - php7-phar \ - php7-pdo_sqlite \ - php7-zip \ - php7-zlib && \ - echo "**** install composer ****" && \ - ln -sf /usr/bin/php7 /usr/bin/php && \ - curl \ - -sS https://getcomposer.org/installer \ - | php -- --install-dir=/usr/bin --filename=composer --version=1.10.17 && \ - composer \ - global require "fxp/composer-asset-plugin:~1.1" && \ - echo "**** install cops ****" && \ - if [ -z ${COPS_RELEASE+x} ]; then \ - COPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/seblucas/cops/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - curl -o \ - /tmp/cops.tar.gz -L \ - "https://github.com/seblucas/cops/archive/${COPS_RELEASE}.tar.gz" && \ - mkdir -p \ - /usr/share/webapps/cops && \ - tar xf /tmp/cops.tar.gz -C \ - /usr/share/webapps/cops --strip-components=1 && \ - cd /usr/share/webapps/cops && \ - composer \ - install --no-dev --optimize-autoloader && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /root/.composer \ - /tmp/* + echo "**** install build packages ****" && \ + apk add --no-cache --upgrade --virtual=build-dependencies \ + curl \ + tar && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache --upgrade \ + php8-ctype \ + php8-dom \ + php8-gd \ + php8-intl \ + php8-mbstring \ + php8-opcache \ + php8-openssl \ + php8-phar \ + php8-pdo_sqlite \ + php8-zip \ + php8-zlib && \ + echo "**** install cops ****" && \ + curl \ + -sS https://getcomposer.org/installer \ + | php -- --install-dir=/usr/bin --filename=composer --version=1.10.26 && \ + composer \ + global require "fxp/composer-asset-plugin:~1.1" && \ + if [ -z ${COPS_RELEASE+x} ]; then \ + COPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/seblucas/cops/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + fi && \ + curl -o \ + /tmp/cops.tar.gz -L \ + "https://github.com/seblucas/cops/archive/${COPS_RELEASE}.tar.gz" && \ + mkdir -p \ + /app/www/public && \ + tar xf /tmp/cops.tar.gz -C \ + /app/www/public --strip-components=1 && \ + cd /app/www/public && \ + composer \ + install --no-dev --optimize-autoloader && \ + sed -i 's|^[[:space:]]*return[[:space:]]@create_function[[:space:]]'\(''\''\$it'\'',[[:space:]]\$func'\)';| return function \(\$it\) use \(\$func\) \{\n return eval\(\$func\);\n \};|' vendor/seblucas/dot-php/doT.php && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /root/.composer \ + /tmp/* # add local files COPY root/ / # ports and volumes -EXPOSE 80 -VOLUME /config /books +EXPOSE 80 443 +VOLUME /config diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 400d7e0..355b355 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.12 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.15 # set version label ARG BUILD_DATE @@ -8,55 +8,54 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="chbmb" RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --upgrade --virtual=build-dependencies \ - curl \ - tar && \ - echo "**** install runtime packages ****" && \ - apk add --no-cache --upgrade \ - php7-ctype \ - php7-dom \ - php7-gd \ - php7-intl \ - php7-mbstring \ - php7-opcache \ - php7-openssl \ - php7-phar \ - php7-pdo_sqlite \ - php7-zip \ - php7-zlib && \ - echo "**** install composer ****" && \ - ln -sf /usr/bin/php7 /usr/bin/php && \ - curl \ - -sS https://getcomposer.org/installer \ - | php -- --install-dir=/usr/bin --filename=composer --version=1.10.17 && \ - composer \ - global require "fxp/composer-asset-plugin:~1.1" && \ - echo "**** install cops ****" && \ - if [ -z ${COPS_RELEASE+x} ]; then \ - COPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/seblucas/cops/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - curl -o \ - /tmp/cops.tar.gz -L \ - "https://github.com/seblucas/cops/archive/${COPS_RELEASE}.tar.gz" && \ - mkdir -p \ - /usr/share/webapps/cops && \ - tar xf /tmp/cops.tar.gz -C \ - /usr/share/webapps/cops --strip-components=1 && \ - cd /usr/share/webapps/cops && \ - composer \ - install --no-dev --optimize-autoloader && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /root/.composer \ - /tmp/* + echo "**** install build packages ****" && \ + apk add --no-cache --upgrade --virtual=build-dependencies \ + curl \ + tar && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache --upgrade \ + php8-ctype \ + php8-dom \ + php8-gd \ + php8-intl \ + php8-mbstring \ + php8-opcache \ + php8-openssl \ + php8-phar \ + php8-pdo_sqlite \ + php8-zip \ + php8-zlib && \ + echo "**** install cops ****" && \ + curl \ + -sS https://getcomposer.org/installer \ + | php -- --install-dir=/usr/bin --filename=composer --version=1.10.26 && \ + composer \ + global require "fxp/composer-asset-plugin:~1.1" && \ + if [ -z ${COPS_RELEASE+x} ]; then \ + COPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/seblucas/cops/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + fi && \ + curl -o \ + /tmp/cops.tar.gz -L \ + "https://github.com/seblucas/cops/archive/${COPS_RELEASE}.tar.gz" && \ + mkdir -p \ + /app/www/public && \ + tar xf /tmp/cops.tar.gz -C \ + /app/www/public --strip-components=1 && \ + cd /app/www/public && \ + composer \ + install --no-dev --optimize-autoloader && \ + sed -i 's|^[[:space:]]*return[[:space:]]@create_function[[:space:]]'\(''\''\$it'\'',[[:space:]]\$func'\)';| return function \(\$it\) use \(\$func\) \{\n return eval\(\$func\);\n \};|' vendor/seblucas/dot-php/doT.php && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /root/.composer \ + /tmp/* # add local files COPY root/ / # ports and volumes -EXPOSE 80 -VOLUME /config /books +EXPOSE 80 443 +VOLUME /config diff --git a/Dockerfile.armhf b/Dockerfile.armhf index a7e7d98..63acecc 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.12 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.15 # set version label ARG BUILD_DATE @@ -8,55 +8,54 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="chbmb" RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --upgrade --virtual=build-dependencies \ - curl \ - tar && \ - echo "**** install runtime packages ****" && \ - apk add --no-cache --upgrade \ - php7-ctype \ - php7-dom \ - php7-gd \ - php7-intl \ - php7-mbstring \ - php7-opcache \ - php7-openssl \ - php7-phar \ - php7-pdo_sqlite \ - php7-zip \ - php7-zlib && \ - echo "**** install composer ****" && \ - ln -sf /usr/bin/php7 /usr/bin/php && \ - curl \ - -sS https://getcomposer.org/installer \ - | php -- --install-dir=/usr/bin --filename=composer --version=1.10.17 && \ - composer \ - global require "fxp/composer-asset-plugin:~1.1" && \ - echo "**** install cops ****" && \ - if [ -z ${COPS_RELEASE+x} ]; then \ - COPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/seblucas/cops/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - curl -o \ - /tmp/cops.tar.gz -L \ - "https://github.com/seblucas/cops/archive/${COPS_RELEASE}.tar.gz" && \ - mkdir -p \ - /usr/share/webapps/cops && \ - tar xf /tmp/cops.tar.gz -C \ - /usr/share/webapps/cops --strip-components=1 && \ - cd /usr/share/webapps/cops && \ - composer \ - install --no-dev --optimize-autoloader && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /root/.composer \ - /tmp/* + echo "**** install build packages ****" && \ + apk add --no-cache --upgrade --virtual=build-dependencies \ + curl \ + tar && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache --upgrade \ + php8-ctype \ + php8-dom \ + php8-gd \ + php8-intl \ + php8-mbstring \ + php8-opcache \ + php8-openssl \ + php8-phar \ + php8-pdo_sqlite \ + php8-zip \ + php8-zlib && \ + echo "**** install cops ****" && \ + curl \ + -sS https://getcomposer.org/installer \ + | php -- --install-dir=/usr/bin --filename=composer --version=1.10.26 && \ + composer \ + global require "fxp/composer-asset-plugin:~1.1" && \ + if [ -z ${COPS_RELEASE+x} ]; then \ + COPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/seblucas/cops/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + fi && \ + curl -o \ + /tmp/cops.tar.gz -L \ + "https://github.com/seblucas/cops/archive/${COPS_RELEASE}.tar.gz" && \ + mkdir -p \ + /app/www/public && \ + tar xf /tmp/cops.tar.gz -C \ + /app/www/public --strip-components=1 && \ + cd /app/www/public && \ + composer \ + install --no-dev --optimize-autoloader && \ + sed -i 's|^[[:space:]]*return[[:space:]]@create_function[[:space:]]'\(''\''\$it'\'',[[:space:]]\$func'\)';| return function \(\$it\) use \(\$func\) \{\n return eval\(\$func\);\n \};|' vendor/seblucas/dot-php/doT.php && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /root/.composer \ + /tmp/* # add local files COPY root/ / # ports and volumes -EXPOSE 80 -VOLUME /config /books +EXPOSE 80 443 +VOLUME /config diff --git a/README.md b/README.md index acf58ef..a15b583 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **20.08.22:** - Rebasing to alpine 3.15 with php8. Restructure nginx configs ([see changes announcement](https://info.linuxserver.io/issues/2022-08-20-nginx-base)). * **22.11.20:** - Pin composer version to 1.10.17. * **01.06.20:** - Rebasing to alpine 3.12. * **19.12.19:** - Rebasing to alpine 3.11. diff --git a/readme-vars.yml b/readme-vars.yml index 463d9d1..150b147 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -84,6 +84,7 @@ app_setup_block: | # changelog changelogs: + - { date: "20.08.22:", desc: "Rebasing to alpine 3.15 with php8. Restructure nginx configs ([see changes announcement](https://info.linuxserver.io/issues/2022-08-20-nginx-base))." } - { date: "22.11.20:", desc: "Pin composer version to 1.10.17." } - { date: "01.06.20:", desc: "Rebasing to alpine 3.12." } - { date: "19.12.19:", desc: "Rebasing to alpine 3.11." } diff --git a/root/defaults/default b/root/defaults/default deleted file mode 100644 index 69e6021..0000000 --- a/root/defaults/default +++ /dev/null @@ -1,40 +0,0 @@ -server { - - listen 80 default_server; -# listen 443 ssl; - server_name _; -# ssl_certificate /config/keys/cert.crt; -# ssl_certificate_key /config/keys/cert.key; - access_log /config/log/nginx/access.log; - error_log /config/log/nginx/error.log; - root /var/www/localhost/cops; - index index.php; - - #Useful only for Kobo reader - location /cops/ { - rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /fetch.php?data=$1&db=$2&type=$3 last; - rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last; - break; - } - - #Can break loading the images - if you don't see anything, comment - location ~ ^/images.*\.(gif|png|ico|jpg)$ { - expires 31d; - } - #Can also break loading the images, comment if it happens - location ~ .(js|css|eot|svg|woff|ttf)$ { - expires 31d; - } - - #Not necessarily correct, it depends on distro. - location ~ \.php$ { - include /etc/nginx/fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_pass 127.0.0.1:9000; - } - - location /books { - root /; - internal; - } -} diff --git a/root/defaults/nginx/site-confs/default.conf.sample b/root/defaults/nginx/site-confs/default.conf.sample new file mode 100644 index 0000000..993a2b1 --- /dev/null +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -0,0 +1,47 @@ +## Version 2022/08/20 - Changelog: https://github.com/linuxserver/docker-cops/commits/master/root/defaults/nginx/site-confs/default.conf.sample + +server { + listen 80 default_server; + listen [::]:80 default_server; + + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; + + server_name _; + + root /app/www/public; + index index.html index.htm index.php; + + #Useful only for Kobo reader + location /cops/ { + rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /fetch.php?data=$1&db=$2&type=$3 last; + rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last; + break; + } + + #Can break loading the images - if you don't see anything, comment + location ~ ^/images.*\.(gif|png|ico|jpg)$ { + expires 31d; + } + #Can also break loading the images, comment if it happens + location ~ .(js|css|eot|svg|woff|ttf)$ { + expires 31d; + } + + location /books { + root /; + internal; + } + + location ~ ^(.+\.php)(.*)$ { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + include /etc/nginx/fastcgi_params; + } + + # deny access to .htaccess/.htpasswd files + location ~ /\.ht { + deny all; + } +} diff --git a/root/etc/cont-init.d/40-config b/root/etc/cont-init.d/40-config index 37302a1..33412ef 100644 --- a/root/etc/cont-init.d/40-config +++ b/root/etc/cont-init.d/40-config @@ -2,30 +2,28 @@ # create folders mkdir -p \ - /config/cache - -# make symlink -[[ ! -e /var/www/localhost/cops ]] && \ - ln -s /usr/share/webapps/cops /var/www/localhost/cops + /config/cache # clear previous config -for f in /var/www/localhost/cops/config_local.*.php +for f in /app/www/public/config_local.*.php do -[ -f "$f" ] && rm "$f" + if [ -f "$f" ]; then + rm "$f" + fi done # copy config -[[ ! -e /config/config_local.php ]] && \ - cp /defaults/config_local.php /config/config_local.php +if [[ ! -e /config/config_local.php ]]; then + cp /defaults/config_local.php /config/config_local.php +fi # copy extra user-profiles for f in /config/config_local*.php do -cp "$f" /var/www/localhost/cops/ +cp "$f" /app/www/public/ done # permissions chown -R abc:abc \ - /config \ - /usr/share/webapps/cops \ - var/www/localhost/cops + /config \ + /app/www/public diff --git a/root/migrations/02-default-location b/root/migrations/02-default-location new file mode 100644 index 0000000..8a66d0c --- /dev/null +++ b/root/migrations/02-default-location @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash + +DEFAULT_CONF="/config/nginx/site-confs/default.conf" +OLD_ROOT="root\s*/var/www/localhost/cops;" +NEW_ROOT="root /app/www/public;" + +if grep -q "${OLD_ROOT}" "${DEFAULT_CONF}";then + echo "updating root in ${DEFAULT_CONF}" + sed -i "s|${OLD_ROOT}|${NEW_ROOT}|" "${DEFAULT_CONF}" +fi diff --git a/root/var/www/localhost/cops/index.html b/root/var/www/localhost/cops/index.html new file mode 100644 index 0000000..2ac31be --- /dev/null +++ b/root/var/www/localhost/cops/index.html @@ -0,0 +1,40 @@ + +
+