diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..390a8d9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +FROM debian:latest +MAINTAINER madmaurice , paul +EXPOSE 8080 443 + +ENV MYSQL_DB cytube +ENV MYSQL_HOST localhost +ENV MYSQL_USER root +ENV MYSQL_PASSWORD toor +ENV MYSQL_PORT 3306 +ENV BASE_URL localhost +ENV COOKIE_SECRET Change_me +ENV YOUTUBE_API_KEY "" + +RUN apt-get update &&\ + apt-get install --no-install-recommends -y \ + netcat \ + npm \ + nodejs \ + mariadb-client \ + ffmpeg \ + git \ + python \ + build-essential \ + wget \ + gettext \ + &&\ + apt-get clean -y &&\ + rm -rf /var/lib/apt/lists/* +RUN npm install -g n &&\ + n stable +# Babel version 7.7.4 is not compatible anymore. +# Therefore we alter the dependencies to refer to 7.4.* instead of 7.* +# Might not be required anymore in the future (01.12.2019) + # sed -i -e '/babel/ s/\^/~/' package.json &&\ +RUN git clone --branch "3.0" --single-branch --depth 1 http://github.com/calzoneman/sync /sync &&\ + cd sync &&\ + npm install &&\ + npm run build-server &&\ + npm run postinstall + +COPY config.template.yaml / +COPY bootstrap.sh / + +RUN chmod +x /bootstrap.sh + +CMD ["/bootstrap.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..77d4795 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +## Cytube +Cytube is a video syncing web application for Youtube, Vimeo, etc. + +### Building and running + +This image has a configuration for Docker Compose, so all you have to do is: + +``` + docker-compose up +``` + diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..b953d77 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +#Waiting for database connection +echo "-- Waiting for mysql database to finish initialization" +while ! nc -vz $MYSQL_HOST $MYSQL_PORT; do sleep 1; done +echo "-- Database initialized." + +envsubst < /config.template.yaml > /sync/config.yaml + +cd sync + +exec node index.js + + diff --git a/config.template.yaml b/config.template.yaml new file mode 100644 index 0000000..1b2d909 --- /dev/null +++ b/config.template.yaml @@ -0,0 +1,196 @@ +mysql: + server: '${MYSQL_HOST}' + port: ${MYSQL_PORT} + database: '${MYSQL_DB}' + user: '${MYSQL_USER}' + password: '${MYSQL_PASSWORD}' + 'pool-size': 10 + + +listen: +# Listen for HTTP + - ip: '0.0.0.0' + port: 8080 + http: true + +# We are using a hack here, in case you need to figure out whats going on. +# As of now, there is no way to set the external port for the links that +# are generated. the `port` is ALWAYS appended, except when it matches +# the protocol of the `domain` set in the `io` section. +# (80 for http, 443 for https). This port is also the listen address +# for the socket.io webserver. Therefore our only choice is to set it to +# '443', so we can use the 'https' schema in the `io` section. +# Listen for Websocket + - ip: '0.0.0.0' + port: 443 # still unencrypted, only for hiding port + io: true + +# HTTP Server details +http: + # Even though you may specify multiple ports to listen on for HTTP above, + # one port must be specified as default for the purposes of generating + # links with the appropriate port + default-port: 443 + domain: 'https://${BASE_URL}' + # Specifies the root domain for cookies. If you have multiple domains + # e.g. a.example.com and b.example.com, the root domain is example.com + root-domain: '${BASE_URL}' + alt-domains: + - '127.0.0.1' + minify: false + # Max-Age for caching. Value should be an integer in milliseconds or a string accepted by + # the `ms` module. Set to 0 to disable caching. + max-age: '7d' + # Set to false to disable gzip compression + gzip: true + # Customize the threshold byte size for applying gzip + gzip-threshold: 1024 + # Secret used for signed cookies. Can be anything, but make it unique and hard to guess + cookie-secret: '${COOKIE_SECRET}' + index: + max-entries: 50 + # Trust reverse proxies (for x-transport-security or x-forwarded-for headers) + trust-proxies: + - "127.0.0.0/8" + - "172.16.0.0/12" # docker network + +# Page template values +# title goes in the upper left corner, description goes in a tag +html-template: + title: 'ZomTube' + description: 'hungry, undead lynchtube' + +# HTTPS server details +https: + enabled: false + # Even though you may specify multiple ports to listen on for HTTPS above, + # one port must be specified as default for the purposes of generating + # links with the appropriate port + default-port: 444 # cause 443 is taken by websockets + domain: 'https://${BASE_URL}' + keyfile: '' + passphrase: '' + certfile: '' + cafile: '' + ciphers: 'HIGH:!DSS:!aNULL@STRENGTH' + # Allow certain account pages to redirect to HTTPS if HTTPS is enabled. + # You may want to set this to false if you are reverse proxying HTTPS to a + # non-HTTPS address. + redirect: true + # try to not actually encrypt anything + keyfile: '' + passphrase: '' + certfile: '' + cafile: '' + +# Socket.io Server details +io: + domain: 'https://${BASE_URL}' + # Even though you may specify multiple ports to listen on for HTTP above, + # one port must be specified as default for the purposes of generating + # links with the appropriate port + default-port: 443 # this doesnt even work, we have to use "80" above to hide this + # limit the number of concurrent socket connections per IP address + ip-connection-limit: 1024 # because of the reverse proxy + +# YouTube v3 API key +# See https://developers.google.com/youtube/registering_an_application +# Google is closing the v2 API (which allowed anonymous requests) on +# April 20, 2015 so you must register a v3 API key now. +# NOTE: You must generate a Server key under Public API access, NOT a +# browser key. +youtube-v3-key: '${YOUTUBE_API_KEY}' +# Path before the channel name +channel-path: 'r' +# Minutes between saving channel state to disk +channel-save-interval: 5 +# Limit for the number of channels a user can register +max-channels-per-user: 5 +# Limit for the number of accounts an IP address can register +max-accounts-per-ip: 5 +# Minimum number of seconds between guest logins from the same IP +guest-login-delay: 60 +channel-storage: + type: 'database' + +# Configure periodic clearing of old alias data +aliases: + # Interval (in milliseconds) between subsequent runs of clearing + purge-interval: 3600000 + # Maximum age of an alias (in milliseconds) - default 1 month + max-age: 2592000000 + +# Workaround for Vimeo blocking my domain +vimeo-workaround: false + +# Regular expressions for defining reserved user and channel names and page titles +# The list of regular expressions will be joined with an OR, and compared without +# case sensitivity. +# +# Default: reserve any name containing "admin[istrator]" or "owner" as a word +# but only if it is separated by a dash or underscore (e.g. dadmin is not reserved +# but d-admin is) +reserved-names: + usernames: + - '^(.*?[-_])?admin(istrator)?([-_].*)?$' + - '^(.*?[-_])?owner([-_].*)?$' + channels: + - '^(.*?[-_])?admin(istrator)?([-_].*)?$' + - '^(.*?[-_])?owner([-_].*)?$' + pagetitles: [] + +# Provide a contact list for the /contact page +contacts: + - name: 'madmaurice' + title: 'Host maintainer' + email: 'madmaurice@zom.bi' + +playlist: + max-items: 4000 + # How often (in seconds), mediaUpdate packets are broadcast to clients + update-interval: 5 + +# If set to true, when the ipThrottle and lastguestlogin rate limiters are cleared +# periodically, the garbage collector will be invoked immediately. +# The server must be invoked with node --expose-gc index.js for this to have any effect. +aggressive-gc: false + +# Allows you to blacklist certain channels. Users will be automatically kicked +# upon trying to join one. +channel-blacklist: [] + +# If you have ffmpeg installed, you can query metadata from raw files, allowing +# server-synched raw file playback. This requires the following: +# * ffmpeg must be installed on the server +ffmpeg: + enabled: true +# Executable name for ffprobe if it is not "ffprobe". On Debian and Ubuntu (on which +# libav is used rather than ffmpeg proper), this is "avprobe" + ffprobe-exec: 'ffprobe' + +link-domain-blacklist: [] + +# Drop root if started as root!! +setuid: + enabled: false + group: 'users' + user: 'user' +# how long to wait in ms before changing uid/gid + timeout: 15 + +# Allows for external services to access the system commandline +# Useful for setups where stdin isn't available such as when using PM2 +# WTF is that??? do not activate!! +service-socket: + enabled: false + socket: 'service.sock' + +# Twitch Client ID for the data API (used for VOD lookups) +# https://github.com/justintv/Twitch-API/blob/master/authentication.md#developer-setup +twitch-client-id: null + +# Mixer Client ID (https://mixer.com/lab) +mixer-client-id: null + +poll: + max-options: 50