From 3f9f861400dae7a737d50ceaa04ac0b8cc62af5a Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sun, 1 Dec 2024 11:08:35 -0700 Subject: [PATCH] change: add two versions, php and non-php --- .github/workflows/deploy-docker.yml | 53 ++++++++ Dockerfile | 25 ++-- Dockerfile-php.template | 134 ++++++++++++++++++++ root/etc/s6-overlay/s6-rc.d/init-php/run | 13 +- root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run | 4 +- 5 files changed, 209 insertions(+), 20 deletions(-) create mode 100644 Dockerfile-php.template diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index 4f10c005..c2e81fc6 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -13,7 +13,28 @@ run-name: "⚙️ Deploy › Docker" # # on: + + # # + # Trigger > Workflow Dispatch + # # + workflow_dispatch: + inputs: + + # # + # true: runs all actions, even ones not scheduled + # false: only scheduled tasks will run + # # + + PRINT_ONLY: + description: "📑 Print Debugs Only" + required: true + default: false + type: boolean + + # # + # Trigger > Push + # # push: tags: @@ -116,6 +137,20 @@ jobs: type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }} type=ref,event=tag + # # + # Release > Github > Debug + # # + + - name: "🪪 Debug › Print" + id: task_release_gh_print + run: | + echo "registry ............. github" + echo "github.actor.......... ${{ github.actor }}" + echo "github.ref ........... ${{ github.ref }}" + echo "github.event_name .... ${{ github.event_name }}" + echo "tags ................. ${{ steps.task_release_gh_meta.outputs.tags }}" + echo "labels ............... ${{ steps.task_release_gh_meta.outputs.labels }}" + # # # Release > Github > Build and Push # # @@ -123,8 +158,10 @@ jobs: - name: "📦 Build and push" id: task_release_gh_push uses: docker/build-push-action@v3 + if: ( github.event_name == 'workflow_dispatch' && inputs.PRINT_ONLY == 'false' ) with: context: . + file: Dockerfile platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.task_release_gh_meta.outputs.tags }} @@ -209,6 +246,20 @@ jobs: type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }} type=ref,event=tag + # # + # Release > Dockerhub > Debug + # # + + - name: "🪪 Debug › Print" + id: task_release_dh_print + run: | + echo "registry ............. dockerhub" + echo "github.actor.......... ${{ github.actor }}" + echo "github.ref ........... ${{ github.ref }}" + echo "github.event_name .... ${{ github.event_name }}" + echo "tags ................. ${{ steps.task_release_dh_meta.outputs.tags }}" + echo "labels ............... ${{ steps.task_release_dh_meta.outputs.labels }}" + # # # Release > Dockerhub > Build and Push # # @@ -216,8 +267,10 @@ jobs: - name: "📦 Build and push" id: task_release_dh_push uses: docker/build-push-action@v3 + if: ( github.event_name == 'workflow_dispatch' && inputs.PRINT_ONLY == 'false' ) with: context: . + file: Dockerfile platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.task_release_dh_meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index c1bd8b25..50d4a40a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,13 @@ # syntax=docker/dockerfile:1 +# # +# @file Dockerfile +# @about This docker file installs: +# - nginx +# - php-fpm +# - theapptv +# # + # # # Base Image # This container uses a modified version of the Linux server alpine image @@ -31,6 +39,7 @@ ARG VERSION ARG NGINX_VERSION ARG CRON_TIME ENV CRON_TIME="0/60 * * * *" +ENV TZ="Etc/UTC" ENV URL_XML="https://raw.githubusercontent.com/dtankdempse/thetvapp-m3u/refs/heads/main/guide/epg.xml" ENV URL_XML_GZ="https://raw.githubusercontent.com/dtankdempse/thetvapp-m3u/refs/heads/main/guide/epg.xml.gz" @@ -55,10 +64,6 @@ RUN \ openssl \ apache2-utils \ nginx \ - php83 \ - php83-fileinfo \ - php83-fpm \ - php83-mbstring \ nginx==${NGINX_VERSION} \ nginx-mod-http-fancyindex==${NGINX_VERSION} && \ echo "**** Install Build Packages ****" && \ @@ -74,18 +79,6 @@ RUN \ rm -f /etc/nginx/http.d/default.conf && \ rm -f /etc/nginx/conf.d/stream.conf && \ rm -f /config/www/index.html && \ - echo "**** Check PHP version and symlink ****" && \ - if [ "$(readlink /usr/bin/php)" != "php83" ]; then \ - rm -rf /usr/bin/php && \ - ln -s /usr/bin/php83 /usr/bin/php; \ - fi && \ - echo "**** Configure PHP ****" && \ - sed -i "s#;error_log = log/php83/error.log.*#error_log = /config/log/php/error.log#g" \ - /etc/php83/php-fpm.conf && \ - sed -i "s#user = nobody.*#user = abc#g" \ - /etc/php83/php-fpm.d/www.conf && \ - sed -i "s#group = nobody.*#group = abc#g" \ - /etc/php83/php-fpm.d/www.conf && \ echo "**** Setup Logrotate ****" && \ sed -i "s#/var/log/messages {}.*# #g" \ /etc/logrotate.conf && \ diff --git a/Dockerfile-php.template b/Dockerfile-php.template new file mode 100644 index 00000000..200aa148 --- /dev/null +++ b/Dockerfile-php.template @@ -0,0 +1,134 @@ +# syntax=docker/dockerfile:1 + +# # +# @file Dockerfile.IncPhp +# @about This docker file installs: +# - nginx +# - php-fpm +# - theapptv +# # + +# # +# Base Image +# This container uses a modified version of the Linux server alpine image +# # + +FROM ghcr.io/linuxserver/baseimage-alpine:3.20 + +# # +# Set Labels +# # + +LABEL maintainer="Aetherinox" +LABEL org.opencontainers.image.authors="Aetherinox" +LABEL org.opencontainers.image.vendor="Aetherinox" +LABEL org.opencontainers.image.title="TheTVApp Grabber" +LABEL org.opencontainers.image.description="thetvapp image by Aetherinox" +LABEL org.opencontainers.image.source="https://github.com/Aetherinox/thetvapp-docker" +LABEL org.opencontainers.image.documentation="https://github.com/Aetherinox/thetvapp-docker" +LABEL org.opencontainers.image.url="https://github.com/Aetherinox/thetvapp-docker" +LABEL org.opencontainers.image.licenses="MIT" +LABEL build_version="1.0.0" + +# # +# Set Args +# # + +ARG BUILD_DATE +ARG VERSION +ARG NGINX_VERSION +ARG CRON_TIME +ENV CRON_TIME="0/60 * * * *" +ENV TZ="Etc/UTC" + +ENV URL_XML="https://raw.githubusercontent.com/dtankdempse/thetvapp-m3u/refs/heads/main/guide/epg.xml" +ENV URL_XML_GZ="https://raw.githubusercontent.com/dtankdempse/thetvapp-m3u/refs/heads/main/guide/epg.xml.gz" +ENV URL_M3U="https://thetvapp-m3u.data-search.workers.dev/playlist" +ENV FILE_NAME="thetvapp" + +ENV PORT_HTTP=80 +ENV PORT_HTTPS=443 + +# # +# Install +# # + +RUN \ + if [ -z ${NGINX_VERSION+x} ]; then \ + NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ + && awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \ + fi && \ + apk add --no-cache \ + wget \ + logrotate \ + openssl \ + apache2-utils \ + nginx \ + php83 \ + php83-fileinfo \ + php83-fpm \ + php83-mbstring \ + nginx==${NGINX_VERSION} \ + nginx-mod-http-fancyindex==${NGINX_VERSION} && \ + echo "**** Install Build Packages ****" && \ + echo "**** Configure Nginx ****" && \ + echo 'fastcgi_param HTTP_PROXY ""; # https://httpoxy.org/' >> \ + /etc/nginx/fastcgi_params && \ + echo 'fastcgi_param PATH_INFO $fastcgi_path_info; # http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info' >> \ + /etc/nginx/fastcgi_params && \ + echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/#connecting-nginx-to-php-fpm' >> \ + /etc/nginx/fastcgi_params && \ + echo 'fastcgi_param SERVER_NAME $host; # Send HTTP_HOST as SERVER_NAME. If HTTP_HOST is blank, send the value of server_name from nginx (default is `_`)' >> \ + /etc/nginx/fastcgi_params && \ + rm -f /etc/nginx/http.d/default.conf && \ + rm -f /etc/nginx/conf.d/stream.conf && \ + rm -f /config/www/index.html && \ + echo "**** Check PHP version and symlink ****" && \ + if [ "$(readlink /usr/bin/php)" != "php83" ]; then \ + rm -rf /usr/bin/php && \ + ln -s /usr/bin/php83 /usr/bin/php; \ + fi && \ + echo "**** Configure PHP ****" && \ + sed -i "s#;error_log = log/php83/error.log.*#error_log = /config/log/php/error.log#g" \ + /etc/php83/php-fpm.conf && \ + sed -i "s#user = nobody.*#user = abc#g" \ + /etc/php83/php-fpm.d/www.conf && \ + sed -i "s#group = nobody.*#group = abc#g" \ + /etc/php83/php-fpm.d/www.conf && \ + echo "**** Setup Logrotate ****" && \ + 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 + +# # +# Set work directory +# # + +WORKDIR /config/www + +# # +# add local files +# # + +COPY root/ / + +# # +# ports and volumes +# # + +EXPOSE ${PORT_HTTP} ${PORT_HTTPS} + +# # +# Add Cron Task Files +# # + +ADD run.sh / +ADD download.sh / + +# # +# In case user sets up the cron for a longer duration, do a first run +# and then keep the container running. Hacky, but whatever. +# # + +CMD ["sh", "-c", "/run.sh ; /download.sh ; tail -f /dev/null"] diff --git a/root/etc/s6-overlay/s6-rc.d/init-php/run b/root/etc/s6-overlay/s6-rc.d/init-php/run index c2894742..1df48898 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-php/run +++ b/root/etc/s6-overlay/s6-rc.d/init-php/run @@ -7,7 +7,9 @@ if [[ ! -f /config/log/php/error.log ]]; then fi # set default timezone -printf "date.timezone = %s\\n" "${TZ:-UTC}" >/etc/php83/conf.d/30_timezone.ini +if [[ -f /etc/php83/conf.d/30_timezone.ini ]]; then + printf "date.timezone = %s\\n" "${TZ:-UTC}" >/etc/php83/conf.d/30_timezone.ini +fi # create local php.ini if it doesn't exist, set local timezone if [[ ! -f /config/php/php-local.ini ]]; then @@ -17,7 +19,10 @@ fi # symlink user php-local.ini to image rm -rf /etc/php83/conf.d/php-local.ini rm -rf /etc/php83/conf.d/zzz_php-local.ini -ln -s /config/php/php-local.ini /etc/php83/conf.d/zzz_php-local.ini + +if [[ -f /config/php/php-local.ini ]] && [ -d /etc/php83/conf.d ]; then + ln -s /config/php/php-local.ini /etc/php83/conf.d/zzz_php-local.ini +fi # create override for www.conf if it doesn't exist if [[ ! -f /config/php/www2.conf ]]; then @@ -25,4 +30,6 @@ if [[ ! -f /config/php/www2.conf ]]; then fi # copy user www2.conf to image -cp /config/php/www2.conf /etc/php83/php-fpm.d/www2.conf +if [[ -f /config/php/www2.conf ]] && [ -d /etc/php83/conf.d ]; then + cp /config/php/www2.conf /etc/php83/php-fpm.d/www2.conf +fi diff --git a/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run index 8d372b04..256fdc5d 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run @@ -1,4 +1,6 @@ #!/usr/bin/with-contenv bash # shellcheck shell=bash -exec /usr/sbin/php-fpm83 -F +if [[ -f /usr/sbin/php-fpm83 ]]; then + exec /usr/sbin/php-fpm83 -F +fi