Peertube image

This commit is contained in:
root 2017-11-03 13:39:41 +00:00
commit 4be5e774ff
5 changed files with 227 additions and 0 deletions

58
Dockerfile Normal file
View File

@ -0,0 +1,58 @@
FROM debian:jessie-slim
ENV UID=991 GID=991 \
HTTPS=false \
HOSTNAME=peertube.localhost \
PORT=80 \
DATABASE_HOST=localhost \
DATABASE_PORT=5432 \
DATABASE_USERNAME=peertube \
DATABASE_PASSWORD=peertube \
ADMIN_EMAIL=admin@domain.local \
SIGNUP_ENABLE=false \
TRANSCODING_ENABLE=false \
TRANSCODING_THREADS=2 \
BODY_SIZE=100M \
CACHE_SIZE=100 \
SIGNUP_LIMIT=10 \
RESOLUTION_280=true \
RESOLUTION_360=true \
RESOLUTION_480=true \
RESOLUTION_720=true \
RESOLUTION_1080=true \
DEBIAN_FRONTEND=noninteractive
RUN echo "deb http://ftp.debian.org/debian jessie-backports main contrib non-free" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y install curl \
&& apt-get -y --no-install-recommends install ffmpeg openssl git build-essential nginx-light \
&& apt-get clean \
&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get -y install -y nodejs yarn --no-install-recommends \
&& git clone --branch develop https://github.com/Chocobozzz/PeerTube /PeerTube \
&& cd /PeerTube \
&& npm install \
&& yarn install \
&& npm run build \
&& apt-get remove --purge --yes build-essential curl git \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /PeerTube/.git \
&& rm -rf /tmp/* /var/lib/apt/lists/* /var/cache/debconf/*-old \
&& rm -rf /usr/share/man/?? \
&& rm -rf /usr/share/man/??_*
EXPOSE 8080
COPY rootfs /
RUN chmod +x /usr/local/bin/startup
WORKDIR /PeerTube/
VOLUME ["/PeerTube/certs", "/PeerTube/videos", "/PeerTube/logs", "/PeerTube/previews", "/PeerTube/thumbnails", "/PeerTube/torrents"]
ENTRYPOINT ["/usr/local/bin/startup"]

40
Dockerfile-alpine Normal file
View File

@ -0,0 +1,40 @@
FROM xataz/nginx
FROM xataz/node:lts
ENV UID=991 GID=991 \
HTTPS=false \
HOSTNAME=peertube.localhost \
PORT=80 \
DATABASE_HOST=localhost \
DATABASE_PORT=5432 \
DATABASE_USERNAME=peertube \
DATABASE_PASSWORD=peertube \
ADMIN_EMAIL=admin@domain.local \
SIGNUP_ENABLE=false \
TRANSCODING_ENABLE=false \
TRANSCODING_THREADS=2 \
BODY_SIZE=100M
RUN apk -U upgrade \
&& apk add -t build-dependencies \
git \
build-base \
g++ \
python \
&& apk -U add yarn ffmpeg libressl su-exec curl\
&& git clone -b develop https://github.com/Chocobozzz/PeerTube /PeerTube \
&& cd /PeerTube \
&& yarn install \
&& npm install \
&& npm run build \
&& apk del build-dependencies \
&& rm -rf /var/cache/apk/* /tmp/* /root/.gnupg /root/.cache/ /PeerTube/.git
COPY rootfs /
RUN chmod +x /usr/local/bin/startup
WORKDIR /PeerTube/
VOLUME ["/PeerTube/certs", "/PeerTube/videos", "/PeerTube/logs", "/PeerTube/previews", "/PeerTube/thumbnails", "/PeerTube/torrents"]
ENTRYPOINT ["/usr/local/bin/startup"]

View File

@ -0,0 +1,49 @@
listen:
port: 9000
# Correspond to your reverse proxy "listen" configuration
webserver:
https: <https>
hostname: '<hostname>'
port: <port>
# Your database name will be "peertube"+database.suffix
database:
hostname: '<database_host>'
port: <database_port>
suffix: '_prod'
username: '<database_username>'
password: '<database_password>'
# From the project root directory
storage:
certs: 'certs/'
videos: 'videos/'
logs: 'logs/'
previews: 'previews/'
thumbnails: 'thumbnails/'
torrents: 'torrents/'
cache:
previews:
size: <cache_size>
admin:
email: '<admin_email>'
signup:
enabled: <signup_enabled>
limit: <signup_limit> # When the limit is reached, registrations are disabled. -1 == unlimited
# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag
# Uses a lot of CPU!
transcoding:
enabled: <transcoding_enable>
threads: <transcoding_threads>
resolutions: # Only created if the original video has a higher resolution
240p: <resolution_280>
360p: <resolution_360>
480p: <resolution_480>
720p: <resolution_720>
1080p: <resolution_1080>

View File

@ -0,0 +1,47 @@
server {
listen 8080;
location / {
proxy_pass http://localhost:9000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# For the video upload
client_max_body_size <body_size>;
}
# Bypass PeerTube webseed route for better performances
location /static/webseed {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
alias /PeerTube/videos;
}
# Websocket tracker
location /tracker/socket {
# Peers send a message to the tracker every 15 minutes
# Don't close the websocket before this time
proxy_read_timeout 1200s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:9000;
}
}

33
rootfs/usr/local/bin/startup Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
#addgroup --gid ${GID} peertube && adduser --disabled-password --shell /bin/sh --gid ${GID} --uid ${UID} --gecos "" peertube
groupadd -g ${GID} peertube && useradd -u ${UID} -M -g ${GID} peertube
sed -i -e 's|<https>|'${HTTPS}'|' \
-e 's|<hostname>|'${HOSTNAME}'|' \
-e 's|<port>|'${PORT}'|' \
-e 's|<database_host>|'${DATABASE_HOST}'|' \
-e 's|<database_port>|'${DATABASE_PORT}'|' \
-e 's|<database_username>|'${DATABASE_USERNAME}'|' \
-e 's|<database_password>|'${DATABASE_PASSWORD}'|' \
-e 's|<admin_email>|'${ADMIN_EMAIL}'|' \
-e 's|<signup_enabled>|'${SIGNUP_ENABLE}'|' \
-e 's|<transcoding_enable>|'${TRANSCODING_ENABLE}'|' \
-e 's|<transcoding_threads>|'${TRANSCODING_THREADS}'|' \
-e 's|<cache_size>|'${CACHE_SIZE}'|' \
-e 's|<signup_limit>|'${SIGNUP_LIMIT}'|' \
-e 's|<resolution_280>|'${RESOLUTION_280}'|' \
-e 's|<resolution_360>|'${RESOLUTION_360}'|' \
-e 's|<resolution_480>|'${RESOLUTION_480}'|' \
-e 's|<resolution_720>|'${RESOLUTION_720}'|' \
-e 's|<resolution_1080>|'${RESOLUTION_1080}'|' /PeerTube/config/production.yaml
sed -i -e 's|<body_size>|'${BODY_SIZE}'|' /etc/nginx/sites-enabled/peertube.conf
chown -R $UID:$GID ./
nginx
if [ $# -eq 0 ]; then
su - peertube -c "cd /PeerTube && NODE_ENV=production npm start"
else
su - peertube -c "cd /PeerTube && NODE_ENV=production npm $#"
fi