commit 23ef55a52d693db7356c0e61ed9367d2fd9d497c Author: dnomd343 Date: Fri Oct 22 16:33:38 2021 +0800 feat: docker of alltube diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f50391 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM alpine as asset +COPY ./ / +RUN sh /asset.sh + +FROM alpine +COPY --from=asset /tmp/alltube/ /var/www/alltube/ +RUN apk --update add --no-cache nginx ffmpeg python3 php php-fpm php-dom php-xml php-zip php-gmp php-json php-phar php-intl php-openssl php-mbstring php-gettext php-xmlwriter php-tokenizer php-simplexml && \ + rm -rf /var/www/localhost && rm -rf /etc/nginx/http.d && \ + mv -f /var/www/alltube/nginx.conf /etc/nginx/ && \ + ln -s /usr/bin/python3 /usr/bin/python && \ + mv /var/www/alltube/init.sh / && \ + php /var/www/alltube/composer-setup.php && rm -f /var/www/alltube/composer-setup.php && \ + mv ./composer.phar /usr/bin/composer && \ + chmod 777 /var/www/alltube/templates_c && \ + cd /var/www/alltube && composer install && \ + cd ./config && mv config.example.yml config.yml +EXPOSE 80 +CMD ["sh","init.sh"] diff --git a/asset.sh b/asset.sh new file mode 100644 index 0000000..d74b370 --- /dev/null +++ b/asset.sh @@ -0,0 +1,12 @@ +get_github_latest_version() { + VERSION=$(curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'); +} + +apk add curl wget +mkdir -p /tmp +get_github_latest_version "Rudloff/alltube" +wget https://github.com/Rudloff/alltube/releases/download/$VERSION/alltube-$VERSION.zip -O /tmp/alltube.zip +unzip -d /tmp/ /tmp/alltube.zip +wget https://install.phpcomposer.com/installer -O /tmp/alltube/composer-setup.php +mv /nginx.conf /tmp/alltube/ +mv /init.sh /tmp/alltube/ diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..a9c595e --- /dev/null +++ b/init.sh @@ -0,0 +1,3 @@ +/usr/sbin/php-fpm7 +/usr/sbin/nginx +read -n 1 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..4806a30 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,47 @@ +user nginx; +worker_processes auto; +pcre_jit on; +include /etc/nginx/modules/*.conf; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + server { + listen 80; + root /var/www/alltube; + index index.php; + + types { + text/html html htm shtml; + text/css css; + text/xml xml; + application/x-web-app-manifest+json webapp; + } + + location ~ /\. { + deny all; + } + + location / { + try_files $uri /index.php?$args; + } + + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + try_files $uri /index.php?$args; + fastcgi_buffers 4 16k; + fastcgi_buffer_size 16k; + fastcgi_index index.php; + fastcgi_intercept_errors off; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_param HTTPS 'ok'; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + } +}