diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 00000000..09cad16c --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,22 @@ +{ + "projectName": "thetvapp-docker", + "projectOwner": "Aetherinox", + "repoType": "github", + "repoHost": "https://github.com", + "files": ["README.md"], + "imageSize": 40, + "commit": true, + "commitConvention": "angular", + "contributors": [ + { + "login": "Aetherinox", + "name": "Aetherinox", + "avatar_url": "https://avatars.githubusercontent.com/u/118329232?v=4", + "profile": "https://gitlab.com/Aetherinox", + "contributions": ["code", "projectManagement"] + } + ], + "contributorsPerLine": 7, + "linkToUsage": false +} + diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..cdb1a82f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gitignore +.github +.gitattributes +READMETEMPLATE.md +README.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..b58e38d6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# http://editorconfig.org + +# is top-most EditorConfig file +root = true + +# All Files +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Markdown Files +[*.md] +trim_trailing_whitespace = false + +# Other +[{*.nsh,*.yml,*.yaml,*.json}] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..bdb0cabc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..77ea0e07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# # +# Windows image file caches +# # + +Thumbs.db +ehthumbs.db + +# # +# Folder config file +# # + +Desktop.ini + +# # +# Recycle Bin used on file shares +# # + +$RECYCLE.BIN/ + +# # +# Windows Installer files +# # + +*.cab +*.msi +*.msm +*.msp + +# # +# Windows shortcuts +# # + +*.lnk + +# # +# Operating System Files +# # + +.DS_Store +.AppleDouble +.LSOverride + +# # +# Thumbnails +# # + +._* + +# # +# Other +# # + +.Spotlight-V100 +.Trashes + +# # +# Directories potentially created on remote AFP share +# # + +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..30936b85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,116 @@ +# syntax=docker/dockerfile:1 + +# # +# Base Image +# This container uses a modified version of the Linux server alpine image +# # + +FROM ghcr.io/linuxserver/baseimage-alpine:3.20 + +# # +# Set Args +# # + +ARG BUILD_DATE +ARG VERSION +ARG NGINX_VERSION +ARG REFRESH +ENV REFRESH="0/15 * * * *" + +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 + +# # +# Set Labels +# # + +LABEL maintainer="Aetherinox" + +# # +# 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/LICENSE b/LICENSE new file mode 100644 index 00000000..db4ed882 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Gistr - Copyright (c) 2025 Aetherinox + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f9bd9f82..e69de29b 100644 --- a/README.md +++ b/README.md @@ -1 +0,0 @@ -# thetvapp-docker diff --git a/download.sh b/download.sh new file mode 100644 index 00000000..63ce40f4 --- /dev/null +++ b/download.sh @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +DATE=$(date '+%m-%d-%Y %H:%M:%S') + +# # +# Run Download +# # + +echo -e +echo -e " Start : Downloading latest ${FILE_NAME} m3u + xml" + +# Download .xml +wget -q -O /config/www/${FILE_NAME}.xml ${URL_XML} +echo -e " Getting ${FILE_NAME}.xml › ${URL_XML}" + +# Download .xml.gz +wget -q -O /config/www/${FILE_NAME}.xml.gz ${URL_XML_GZ} +echo -e " Getting ${FILE_NAME}.xml.gz › ${URL_XML_GZ}" + +# Download .m3u8 +wget -q -O /config/www/${FILE_NAME}.m3u8 ${URL_M3U} +echo -e " Getting ${FILE_NAME}.m3u8 › ${URL_M3U}" + +echo -e " End : Finished update at ${DATE}" diff --git a/root/defaults/nginx/dhparams.pem b/root/defaults/nginx/dhparams.pem new file mode 100644 index 00000000..eed4c41e --- /dev/null +++ b/root/defaults/nginx/dhparams.pem @@ -0,0 +1,13 @@ +-----BEGIN DH PARAMETERS----- +MIICCAKCAgEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz ++8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a +87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7 +YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi +7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD +ssbzSibBsu/6iGtCOGEfz9zeNVs7ZRkDW7w09N75nAI4YbRvydbmyQd62R0mkff3 +7lmMsPrBhtkcrv4TCYUTknC0EwyTvEN5RPT9RFLi103TZPLiHnH1S/9croKrnJ32 +nuhtK8UiNjoNq8Uhl5sN6todv5pC1cRITgq80Gv6U93vPBsg7j/VnXwl5B0rZp4e +8W5vUsMWTfT7eTDp5OWIV7asfV9C1p9tGHdjzx1VA0AEh/VbpX4xzHpxNciG77Qx +iu1qHgEtnmgyqQdgCpGBMMRtx3j5ca0AOAkpmaMzy4t6Gh25PXFAADwqTs6p+Y0K +zAqCkc3OyX3Pjsm1Wn+IpGtNtahR9EGC4caKAH5eZV9q//////////8CAQI= +-----END DH PARAMETERS----- \ No newline at end of file diff --git a/root/defaults/nginx/nginx.conf.sample b/root/defaults/nginx/nginx.conf.sample new file mode 100644 index 00000000..34187582 --- /dev/null +++ b/root/defaults/nginx/nginx.conf.sample @@ -0,0 +1,90 @@ +# # +# @project thetvapp-docker +# @about Nginx site-configs default configuration file +# @file /root/defaults/nginx/nginx.conf.sample +# @repo https://github.com/Aetherinox/thetvapp-docker +# @generated 2024-11-30 +# # + +user abc; + +# Set number of worker processes automatically based on number of CPU cores. +include /config/nginx/worker_processes.conf; + +# Enables the use of JIT for regular expressions to speed-up their processing. +pcre_jit on; + +# Configures default error logger. +error_log /config/log/nginx/error.log; + +# Includes files with directives to load dynamic modules. +include /etc/nginx/modules/*.conf; + +# Include files with config snippets into the root context. +include /etc/nginx/conf.d/*.conf; + +events +{ + # The maximum number of simultaneous connections that can be opened by + # a worker process. + worker_connections 1024; +} + +http +{ + # Includes mapping of file name extensions to MIME types of responses + # and defines the default type. + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Name servers used to resolve names of upstream servers into addresses. + # It's also needed when using tcpsocket and udpsocket in Lua modules. + #resolver 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001; + include /config/nginx/resolver.conf; + + # Don't tell nginx version to the clients. Default is 'on'. + server_tokens off; + + # Specifies the maximum accepted body size of a client request, as + # indicated by the request header Content-Length. If the stated content + # length is greater than this size, then the client receives the HTTP + # error code 413. Set to 0 to disable. Default is '1m'. + client_max_body_size 0; + + # Sendfile copies data between one FD and other from within the kernel, + # which is more efficient than read() + write(). Default is off. + sendfile on; + + # Causes nginx to attempt to send its HTTP response head in one packet, + # instead of using partial frames. Default is 'off'. + tcp_nopush on; + + # all ssl related config moved to ssl.conf + # included in server blocks where listen 443 is defined + + # Enable gzipping of responses. + #gzip on; + + # Set the Vary HTTP header as defined in the RFC 2616. Default is 'off'. + gzip_vary on; + + # Helper variable for proxying websockets. + map $http_upgrade $connection_upgrade + { + default upgrade; + '' close; + } + + # Enable http2 by default for all servers + http2 on; + + # Sets the path, format, and configuration for a buffered log write. + access_log /config/log/nginx/access.log; + + # Includes virtual hosts configs. + include /etc/nginx/http.d/*.conf; + include /config/nginx/site-confs/*.conf; +} + +daemon off; +pid /run/nginx.pid; 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 00000000..a4005060 --- /dev/null +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -0,0 +1,81 @@ +# # +# @project thetvapp-docker +# @about Nginx site-configs default configuration file +# @file /root/defaults/nginx/site-confs/default.conf +# @repo https://github.com/Aetherinox/thetvapp-docker +# @generated 2024-11-30 +# # + +server +{ + listen 80 default_server; + listen [::]:80 default_server; + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + + server_name _; + + include /config/nginx/ssl.conf; + + set $root /app/www/public; + if (!-d /app/www/public) + { + set $root /config/www; + } + + root $root; + index index.html index.htm index.php; + + location / + { + # enable for basic auth + #auth_basic "Restricted"; + #auth_basic_user_file /config/nginx/.htpasswd; + + # index > fancy + fancyindex on; + fancyindex_header "/theme/header.html"; + fancyindex_footer "/theme/footer.html"; + fancyindex_ignore "theme"; + fancyindex_time_format "%m-%d-%Y %T"; + fancyindex_name_length 255; + fancyindex_show_dotfiles off; + fancyindex_hide_symlinks on; + fancyindex_default_sort name; + + # index > auto + autoindex_exact_size off; + autoindex_format html; + autoindex_localtime on; + + gzip on; + gzip_vary on; + gzip_types text/css text/javascript text/xml application/atom+xml application/rss+xml text/markdown text/mathml text/plain text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component application/json application/xhtml+xml application/xspf+xml font/woff font/woff2 image/avif image/bmp image/png image/svg+xml image/tiff image/vnd.wap.wbmp image/webp image/x-icon image/x-jng audio/midi audio/mpeg audio/ogg audio/x-m4a audio/x-realaudio; + gzip_proxied any; + gzip_comp_level 1; + gzip_http_version 1.0; + gunzip on; + gzip_static on; + + try_files $uri $uri/ /index.html /index.htm /index.php$is_args$args; + } + + location ~ ^(.+\.php)(.*)$ + { + # enable the next two lines for http auth + #auth_basic "Restricted"; + #auth_basic_user_file /config/nginx/.htpasswd; + + fastcgi_split_path_info ^(.+\.php)(.*)$; + if (!-f $document_root$fastcgi_script_name) { return 404; } + 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/defaults/nginx/ssl.conf.sample b/root/defaults/nginx/ssl.conf.sample new file mode 100644 index 00000000..6f9b6d61 --- /dev/null +++ b/root/defaults/nginx/ssl.conf.sample @@ -0,0 +1,45 @@ +# # +# @project thetvapp-docker +# @about Nginx site-configs default configuration file +# @file /root/defaults/nginx/ssl.conf.sample +# @repo https://github.com/Aetherinox/thetvapp-docker +# @generated 2024-11-30 +# # + +### Mozilla Recommendations +# generated 2023-06-25, Mozilla Guideline v5.7, nginx 1.24.0, OpenSSL 3.1.1, intermediate configuration +# https://ssl-config.mozilla.org/#server=nginx&version=1.24.0&config=intermediate&openssl=3.1.1&guideline=5.7 + +ssl_certificate /config/keys/cert.crt; +ssl_certificate_key /config/keys/cert.key; +ssl_session_timeout 1d; +ssl_session_cache shared:MozSSL:10m; # about 40000 sessions +ssl_session_tickets off; + +# curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam +ssl_dhparam /config/nginx/dhparams.pem; + +# intermediate configuration +ssl_protocols TLSv1.2 TLSv1.3; +ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305; +ssl_prefer_server_ciphers off; + +# HSTS (ngx_http_headers_module is required) (63072000 seconds) +#add_header Strict-Transport-Security "max-age=63072000" always; + +# OCSP stapling +#ssl_stapling on; +#ssl_stapling_verify on; + +# verify chain of trust of OCSP response using Root CA and Intermediate certs +#ssl_trusted_certificate /config/keys/cert.crt; + +# Optional additional headers +#add_header Cache-Control "no-transform" always; +#add_header Content-Security-Policy "upgrade-insecure-requests; frame-ancestors 'self'" always; +#add_header Permissions-Policy "interest-cohort=()" always; +#add_header Referrer-Policy "same-origin" always; +#add_header X-Content-Type-Options "nosniff" always; +#add_header X-Frame-Options "SAMEORIGIN" always; +#add_header X-UA-Compatible "IE=Edge" always; +#add_header X-XSS-Protection "1; mode=block" always; diff --git a/root/defaults/www/index.html b/root/defaults/www/index.html new file mode 100644 index 00000000..8351def0 --- /dev/null +++ b/root/defaults/www/index.html @@ -0,0 +1,34 @@ + +
+