Skip to content

Commit b3f30f1

Browse files
author
Daniel Neto
committed
Update
1 parent f636f02 commit b3f30f1

25 files changed

+520
-135
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,5 @@ view/videoComments_bkp.php
8484
/.compose/
8585
test.php
8686
/plugin/JosephZ/
87+
/Encoder/
88+
/.env

Dockerfile

+55-55
Original file line numberDiff line numberDiff line change
@@ -10,94 +10,94 @@ LABEL maintainer="TRW <trw@acoby.de>" \
1010

1111
ARG DEBIAN_FRONTEND=noninteractive
1212

13-
ENV DB_MYSQL_HOST database
14-
ENV DB_MYSQL_PORT 3306
15-
ENV DB_MYSQL_NAME avideo
16-
ENV DB_MYSQL_USER avideo
17-
ENV DB_MYSQL_PASSWORD avideo
18-
19-
ENV SERVER_NAME localhost
20-
ENV ENABLE_PHPMYADMIN yes
21-
ENV CREATE_TLS_CERTIFICATE yes
22-
ENV TLS_CERTIFICATE_FILE /etc/apache2/ssl/localhost.crt
23-
ENV TLS_CERTIFICATE_KEY /etc/apache2/ssl/localhost.key
24-
ENV CONTACT_EMAIL admin@localhost
25-
ENV SYSTEM_ADMIN_PASSWORD password
26-
ENV WEBSITE_TITLE AVideo
27-
ENV MAIN_LANGUAGE en_US
28-
29-
ENV HTTPS_PORT $HTTPS_PORT
13+
ARG SOCKET_PORT
14+
ARG HTTP_PORT
15+
ARG HTTPS_PORT
16+
ARG NGINX_RTMP_PORT
17+
ARG NGINX_HTTP_PORT
18+
ARG NGINX_HTTPS_PORT
19+
ARG DB_MYSQL_HOST
20+
ARG DB_MYSQL_PORT
21+
ARG DB_MYSQL_NAME
22+
ARG DB_MYSQL_USER
23+
ARG DB_MYSQL_PASSWORD
24+
ARG SERVER_NAME
25+
ARG CREATE_TLS_CERTIFICATE
26+
ARG TLS_CERTIFICATE_FILE
27+
ARG TLS_CERTIFICATE_KEY
28+
ARG CONTACT_EMAIL
29+
ARG SYSTEM_ADMIN_PASSWORD
30+
ARG WEBSITE_TITLE
31+
ARG MAIN_LANGUAGE
3032

3133
# Retrieve package list
3234
RUN apt update
3335

3436
# Install dependencies
3537
RUN apt-get update -y && apt-get upgrade -y \
36-
&& apt install -y --no-install-recommends ca-certificates apt-transport-https software-properties-common curl \
38+
&& apt install -y --no-install-recommends dos2unix bash-completion lsof cron rsync ca-certificates apt-transport-https software-properties-common curl \
3739
&& curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp \
3840
&& chmod a+rx /usr/local/bin/yt-dlp \
39-
&& apt install -y --no-install-recommends sshpass nano net-tools curl apache2 php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-curl php8.1-gd php8.1-intl \
40-
php-zip mysql-client ffmpeg git libimage-exiftool-perl libapache2-mod-xsendfile -y && a2enmod xsendfile && cd /var/www/html \
41-
&& git clone https://github.com/WWBN/AVideo.git \
41+
&& apt install -y --no-install-recommends sshpass nano net-tools curl apache2 php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-sqlite3 php8.1-curl php8.1-gd php8.1-intl \
42+
php-zip mysql-client ffmpeg git libimage-exiftool-perl libapache2-mod-xsendfile python3-certbot-apache -y && a2enmod xsendfile && cd /var/www/html \
4243
&& apt install -y --no-install-recommends && curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl \
4344
&& chmod a+rx /usr/local/bin/youtube-dl && apt install -y --no-install-recommends build-essential libpcre3 libpcre3-dev libssl-dev php8.1-xml -y \
44-
&& a2enmod rewrite && chown www-data:www-data /var/www/html/AVideo/plugin && chmod 755 /var/www/html/AVideo/plugin \
45+
&& a2enmod rewrite \
4546
&& apt install -y --no-install-recommends unzip -y && apt install -y --no-install-recommends htop python3-pip \
4647
&& pip3 install youtube-dl && pip3 install --upgrade youtube-dl && a2enmod expires \
4748
&& a2enmod headers
4849

4950
COPY deploy/apache/avideo.conf /etc/apache2/sites-enabled/000-default.conf
50-
COPY deploy/apache/phpmyadmin.conf /etc/apache2/conf-available/phpmyadmin.conf
5151
COPY deploy/docker-entrypoint /usr/local/bin/docker-entrypoint
5252
COPY deploy/wait-for-db.php /usr/local/bin/wait-for-db.php
5353

54-
COPY admin /var/www/html/AVideo/admin
55-
COPY feed /var/www/html/AVideo/feed
56-
COPY install /var/www/html/AVideo/install
57-
COPY locale /var/www/html/AVideo/locale
58-
COPY node_modules /var/www/html/AVideo/node_modules
59-
COPY objects /var/www/html/AVideo/objects
60-
COPY plugin /var/www/html/AVideo/plugin
61-
COPY storage /var/www/html/AVideo/storage
62-
COPY updatedb /var/www/html/AVideo/updatedb
63-
COPY vendor /var/www/html/AVideo/vendor
64-
COPY view /var/www/html/AVideo/view
65-
COPY _config.yml /var/www/html/AVideo
66-
COPY .htaccess /var/www/html/AVideo
67-
COPY CNAME /var/www/html/AVideo
68-
COPY LICENSE /var/www/html/AVideo
69-
COPY README.md /var/www/html/AVideo
70-
COPY web.config /var/www/html/AVideo
71-
COPY index.php /var/www/html/AVideo
72-
COPY git.json.php /var/www/html/AVideo
73-
COPY sw.js /var/www/html/AVideo/
54+
# Install nginx
55+
RUN apt-get install build-essential libssl-dev libpcre3 libpcre3-dev wget -y \
56+
&& apt-get install --reinstall zlib1g zlib1g-dev -y \
57+
&& mkdir /var/www/tmp && chmod -R 777 /var/www/tmp \
58+
&& mkdir /HLS && mkdir /HLS/live && chmod -R 777 /HLS
59+
60+
RUN mkdir ~/build \
61+
&& cd ~/build \
62+
&& git clone https://github.com/arut/nginx-rtmp-module.git \
63+
&& git clone https://github.com/nginx/nginx.git \
64+
&& cd nginx \
65+
&& ./auto/configure --with-http_ssl_module --with-http_stub_status_module --add-module=../nginx-rtmp-module --with-cc-opt="-Wimplicit-fallthrough=0" \
66+
&& make \
67+
&& make install\
68+
&& cd /usr/local/nginx/html && wget https://youphp.tube/docs/stat.xsl
69+
70+
COPY deploy/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf
71+
72+
COPY deploy/crontab /etc/cron.d/crontab
73+
RUN chmod 0644 /etc/cron.d/crontab
7474

7575
# Configure AVideo
76-
RUN chmod 755 /usr/local/bin/docker-entrypoint && \
76+
RUN dos2unix /usr/local/bin/docker-entrypoint && \
77+
chmod 755 /usr/local/bin/docker-entrypoint && \
78+
chmod +x /usr/local/bin/docker-entrypoint && \
7779
pip3 install youtube-dl && \
78-
cd /var/www/html/AVideo && \
79-
git config --global advice.detachedHead false && \
80-
git clone https://github.com/WWBN/AVideo-Encoder.git Encoder && \
81-
chown -R www-data:www-data /var/www/html/AVideo && \
82-
cd /var/www/html/AVideo/plugin/User_Location/install && \
83-
unzip install.zip && \
8480
sed -i 's/^post_max_size.*$/post_max_size = 10G/' /etc/php/8.1/apache2/php.ini && \
8581
sed -i 's/^upload_max_filesize.*$/upload_max_filesize = 10G/' /etc/php/8.1/apache2/php.ini && \
82+
sed -i 's/^max_execution_time.*$/max_execution_time = 7200/' /etc/php/8.1/apache2/php.ini && \
83+
sed -i 's/^memory_limit.*$/memory_limit = 512M/' /etc/php/8.1/apache2/php.ini && \
8684
a2enmod rewrite expires headers ssl xsendfile
8785

86+
# Add Apache configuration
87+
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
88+
8889
VOLUME /var/www/tmp
8990
RUN mkdir -p /var/www/tmp && \
9091
chown www-data:www-data /var/www/tmp && \
9192
chmod 777 /var/www/tmp
9293

93-
VOLUME /var/www/html/AVideo/videos
94-
RUN mkdir -p /var/www/html/AVideo/videos && \
95-
chown www-data:www-data /var/www/html/AVideo/videos && \
96-
chmod 777 /var/www/html/AVideo/videos
97-
9894
WORKDIR /var/www/html/AVideo/
9995

96+
EXPOSE $SOCKET_PORT
97+
EXPOSE $HTTP_PORT
10098
EXPOSE $HTTPS_PORT
99+
EXPOSE $NGINX_RTMP_PORT
100+
EXPOSE $NGINX_HTTPS_PORT
101101

102102
ENTRYPOINT ["/usr/local/bin/docker-entrypoint"]
103103
CMD ["apache2-foreground"]

deploy/apache/avideo.conf

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1-
<VirtualHost *:80>
2-
ServerName SERVER_NAME
1+
<VirtualHost localhost:80>
2+
ServerName localhost
33
ServerAdmin CONTACT_EMAIL
44
DocumentRoot "/var/www/html/AVideo"
5-
65
ErrorLog /dev/stderr
6+
CustomLog ${APACHE_LOG_DIR}/access.log combined
77
TransferLog /dev/stdout
8-
9-
RewriteEngine On
10-
RewriteCond %{HTTPS} off
11-
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
128
</VirtualHost>
13-
14-
<VirtualHost *:443>
15-
ServerName SERVER_NAME
9+
<VirtualHost localhost:443>
10+
ServerName localhost
1611
ServerAdmin CONTACT_EMAIL
1712
DocumentRoot "/var/www/html/AVideo"
1813

1914
ErrorLog /dev/stderr
15+
CustomLog ${APACHE_LOG_DIR}/access.log combined
2016
TransferLog /dev/stdout
2117

2218
SSLEngine on
2319
SSLCertificateFile TLS_CERTIFICATE_FILE
2420
SSLCertificateKeyFile TLS_CERTIFICATE_KEY
2521
</VirtualHost>
26-
22+
<VirtualHost *:80>
23+
ServerName SERVER_NAME
24+
ServerAdmin CONTACT_EMAIL
25+
DocumentRoot "/var/www/html/AVideo"
26+
ErrorLog /dev/stderr
27+
CustomLog ${APACHE_LOG_DIR}/access.log combined
28+
TransferLog /dev/stdout
29+
</VirtualHost>
30+
<VirtualHost *:443>
31+
ServerName SERVER_NAME
32+
ServerAdmin CONTACT_EMAIL
33+
DocumentRoot "/var/www/html/AVideo"
34+
ErrorLog /dev/stderr
35+
CustomLog ${APACHE_LOG_DIR}/access.log combined
36+
TransferLog /dev/stdout
37+
</VirtualHost>
2738
<Directory /var/www/html/AVideo/>
2839
Options Indexes FollowSymLinks
2940
XSendFile on

deploy/apache/localhost.conf

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<VirtualHost localhost:80>
2+
ServerName SERVER_NAME
3+
ServerAlias localhost
4+
ServerAdmin CONTACT_EMAIL
5+
DocumentRoot "/var/www/html/AVideo"
6+
7+
ErrorLog /dev/stderr
8+
CustomLog ${APACHE_LOG_DIR}/access.log combined
9+
TransferLog /dev/stdout
10+
</VirtualHost>
11+
<VirtualHost localhost:443>
12+
ServerName SERVER_NAME
13+
ServerAlias localhost
14+
ServerAdmin CONTACT_EMAIL
15+
DocumentRoot "/var/www/html/AVideo"
16+
17+
ErrorLog /dev/stderr
18+
CustomLog ${APACHE_LOG_DIR}/access.log combined
19+
TransferLog /dev/stdout
20+
21+
SSLEngine on
22+
SSLCertificateFile TLS_CERTIFICATE_FILE
23+
SSLCertificateKeyFile TLS_CERTIFICATE_KEY
24+
</VirtualHost>
25+
<Directory /var/www/html/AVideo/>
26+
Options Indexes FollowSymLinks
27+
XSendFile on
28+
XSendFilePath /var/www/html/AVideo/
29+
AllowOverride All
30+
Require all granted
31+
Order Allow,Deny
32+
Allow from All
33+
</Directory>

deploy/crontab

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# m h dom mon dow command
2+
1 1 * * * pip3 install --upgrade youtube-dl
3+
* * * * * php /var/www/html/AVideo/plugin/Scheduler/run.php
4+
#2 1 * * * php /var/www/html/AVideo/plugin/CDN/tools/moveMissingFiles.php

deploy/docker-entrypoint

+77-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
echo "Starting AVideo Platform..."
44
CONFIG_FILE=/etc/apache2/sites-enabled/000-default.conf
5+
CONFIG_NGINX_FILE=/usr/local/nginx/conf/nginx.conf
56

67
if [ "_${CREATE_TLS_CERTIFICATE}_" == "_yes_" ]; then
78
echo "Generate Certificate..."
@@ -42,18 +43,25 @@ if [ "_${CREATE_TLS_CERTIFICATE}_" == "_yes_" ]; then
4243
openssl x509 -in ${TLS_CERTIFICATE_FILE} -noout -text || true
4344
fi
4445

45-
echo "Configure Apache..."
4646
sed -i 's#SERVER_NAME#'${SERVER_NAME}'#' ${CONFIG_FILE}
47+
sed -i 's#CONTACT_EMAIL#'${CONTACT_EMAIL}'#' ${CONFIG_FILE}
48+
sed -i 's#server_name localhost _#server_name localhost _ '${SERVER_NAME}'#' ${CONFIG_NGINX_FILE}
49+
50+
echo "Configure Apache..."
4751
sed -i 's#TLS_CERTIFICATE_FILE#'${TLS_CERTIFICATE_FILE}'#' ${CONFIG_FILE}
4852
sed -i 's#TLS_CERTIFICATE_KEY#'${TLS_CERTIFICATE_KEY}'#' ${CONFIG_FILE}
49-
sed -i 's#CONTACT_EMAIL#'${CONTACT_EMAIL}'#' ${CONFIG_FILE}
5053

51-
if [ "_${ENABLE_PHPMYADMIN}_" = "_yes_" ]; then
52-
echo "Enabling local PHPMyAdmin on https://${SERVER_NAME}/phpmyadmin"
53-
cp /etc/apache2/conf-available/phpmyadmin.conf /etc/apache2/conf-enabled/phpmyadmin.conf
54-
a2enmod proxy
55-
a2enmod proxy_http
56-
fi
54+
echo "Configure Nginx..."
55+
sed -i 's#ssl_certificate /etc/apache2/ssl/localhost.crt#ssl_certificate '${TLS_CERTIFICATE_FILE}'#' ${CONFIG_NGINX_FILE}
56+
sed -i 's#ssl_certificate_key /etc/apache2/ssl/localhost.key#ssl_certificate_key '${TLS_CERTIFICATE_KEY}'#' ${CONFIG_NGINX_FILE}
57+
sed -i 's#listen 1935#listen '${NGINX_RTMP_PORT}'#' ${CONFIG_NGINX_FILE}
58+
sed -i 's#listen 8080#listen '${NGINX_HTTP_PORT}'#' ${CONFIG_NGINX_FILE}
59+
sed -i 's#listen 8443#listen '${NGINX_HTTPS_PORT}'#' ${CONFIG_NGINX_FILE}
60+
61+
mkdir -p /etc/letsencrypt/live/localhost/
62+
63+
cp ${TLS_CERTIFICATE_FILE} /etc/letsencrypt/live/localhost/fullchain.pem
64+
cp ${TLS_CERTIFICATE_KEY} /etc/letsencrypt/live/localhost/privkey.pem
5765

5866
echo "Waiting for database ${DB_MYSQL_HOST} to be up and running"
5967
php /usr/local/bin/wait-for-db.php
@@ -62,14 +70,69 @@ if [ $? -ne 0 ]; then
6270
exit 1
6371
fi
6472

65-
if [ -f /var/www/html/AVideo/videos/configuration.php ]; then
66-
echo "Using existing configuration..."
73+
if [ -f /var/www/html/AVideo/plugin/User_Location/install/install.sql ]; then
74+
echo "Using existing location tables..."
75+
else
76+
echo "Create new locations tables..."
77+
cd /var/www/html/AVideo/plugin/User_Location/install && unzip install.zip
78+
# Configure AVideo Encoder
79+
cd /var/www/html/AVideo && git config --global advice.detachedHead false && git clone https://github.com/WWBN/AVideo-Encoder.git Encoder
80+
# Configure AVideo permissions
81+
chown -R www-data:www-data /var/www/html/AVideo
82+
fi
83+
84+
if [ -f /var/www/html/AVideo/Encoder/index.php ]; then
85+
echo "Using existing Encoder configuration..."
86+
else
87+
echo "Create new Encoder configuration..."
88+
# Configure AVideo Encoder
89+
cd /var/www/html/AVideo && git config --global advice.detachedHead false && git clone https://github.com/WWBN/AVideo-Encoder.git Encoder
90+
fi
91+
92+
if [ -d /var/www/html/AVideo/Encoder/videos ]; then
93+
echo "Using existing Encoder videos..."
6794
else
68-
echo "Create new configuration..."
69-
cd /var/www/html/AVideo/install/
70-
php ./cli.php
71-
cd /var/www/html/AVideo/
95+
echo "Create new Encoder videos..."
96+
# Configure AVideo Encoder
97+
mkdir -p /var/www/html/AVideo/Encoder/videos && chown www-data:www-data /var/www/html/AVideo/Encoder/videos && chmod 777 /var/www/html/AVideo/Encoder/videos
98+
fi
99+
100+
echo "Checking configuration..."
101+
cd /var/www/html/AVideo/install/
102+
php ./cli.php
103+
cd /var/www/html/AVideo/
104+
105+
echo "lets encrypt apache ${SERVER_NAME}"
106+
certbot --apache --non-interactive --agree-tos --register-unsafely-without-email --redirect --keep-until-expiring -d ${SERVER_NAME}
107+
108+
/etc/init.d/apache2 stop
109+
110+
if [ -f /usr/local/nginx/sbin/nginx ]; then
111+
/usr/local/nginx/sbin/nginx -s stop
112+
echo "lets encrypt nginx ${SERVER_NAME}"
113+
apt-get install -y --no-install-recommends python3-certbot-nginx
114+
mv /usr/sbin/nginx /usr/sbin/nginx.old && cp /usr/local/nginx/sbin/nginx /usr/sbin/nginx
115+
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old && cp /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf
116+
certbot --nginx --non-interactive --agree-tos --nginx-server-root /usr/local/nginx/conf --no-redirect --register-unsafely-without-email --keep-until-expiring -d $SERVER_NAME
117+
sed -i 's/listen 443 ssl/listen 8443 ssl/g' /usr/local/nginx/conf/nginx.conf
118+
echo "nginx start"
119+
/usr/local/nginx/sbin/nginx -s stop && sleep 3 && /usr/local/nginx/sbin/nginx
72120
fi
73121

122+
nohup php /var/www/html/AVideo/plugin/YPTSocket/server.php &
123+
echo "socket done"
124+
125+
echo "Reset log"
126+
echo '' > /var/www/html/AVideo/videos/avideo.log
127+
chmod 777 /var/www/html/AVideo/videos/avideo.log
128+
129+
echo "deny access to .compose"
130+
echo "Deny from all" > /var/www/html/AVideo/.compose/.htaccess
131+
74132
apache2-foreground
133+
echo "apache2-foreground done"
134+
135+
cd /var/www/html/AVideo/install && php updatedb.php && installPluginsTables.php 4
136+
cd /var/www/html/AVideo/Encoder/install && php reencodeAllVideos.php
137+
75138
#eof

0 commit comments

Comments
 (0)