Skip to content

Commit 0233e95

Browse files
committed
docker support
1 parent 7921f41 commit 0233e95

6 files changed

Lines changed: 377 additions & 2 deletions

File tree

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM alpine:3.6
2+
3+
ADD . /app
4+
5+
RUN cd app && sh container-install.sh
6+
7+
WORKDIR /app
8+
9+
ENV MYSQL_HOST localhost
10+
ENV MYSQL_PORT 3306
11+
ENV MYSQL_DATABASE cytube
12+
ENV MYSQL_USER cytube
13+
ENV MYSQL_PASSWORD nico_best_girl
14+
ENV MYSQL_ROOT_PASSWORD ruby_best_girl
15+
ENV SYNC_TITLE Sync
16+
ENV SYNC_DESCRIPTION Sync Video
17+
ENV ROOT_URL http://localhost:8080
18+
ENV ROOT_PORT 8080
19+
ENV IO_ROOT_URL http://localhost
20+
ENV IO_ROOT_PORT 1337
21+
ENV ROOT_DOMAIN localhost:8080
22+
ENV HTTPS_ENABLED false
23+
ENV TRUST_ALL_PROXIES false
24+
#ENV YOUTUBE_KEY
25+
#ENV TWITCH_CLIENT_ID
26+
27+
EXPOSE 8080
28+
# EXPOSE 1337
29+
# EXPOSE 8443
30+
31+
ADD conf /app/conf
32+
ADD config.template.docker.yaml /app/config.template.yaml
33+
ADD run.sh /app/run.sh
34+
35+
WORKDIR /app
36+
37+
CMD ["sh", "run.sh"]

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ General help with the software and the website is also available on the IRC
3737
channel at [irc.esper.net#cytube](http://webchat.esper.net/?channels=cytube)
3838
during US daytime hours.
3939

40+
Docker
41+
------
42+
43+
Example for using the dockerfile on this repo.
44+
45+
```
46+
docker build -t sync .
47+
docker network create sync
48+
49+
docker run -d --name sync-db \
50+
-e MARIADB_ROOT_PASSWORD='abcdefg123456' \
51+
-e MARIADB_DATABASE=cytube \
52+
-e MARIADB_USER=cytube \
53+
-e MARIADB_PASSWORD=aaaaa \
54+
--network sync mariadb
55+
56+
docker run -d --name sync-web \
57+
-e MYSQL_HOST=sync-db \
58+
-e MYSQL_PASSWORD=aaaaa \
59+
-e ROOT_URL=https://cytube.my.domain \
60+
-e IO_ROOT_URL=https://cytube.my.domain \
61+
-e ROOT_DOMAIN=cytube.my.domain \
62+
-e VIRTUAL_HOST=cytube.my.domain \
63+
-e VIRTUAL_PORT=8080 \
64+
-e LETSENCRYPT_HOST=cytube.my.domain \
65+
-e YOUTUBE_KEY=abcdefg \
66+
--network sync sync
67+
```
68+
69+
Feedback
70+
--------
71+
4072
## License
4173

4274
Original source code in this repository is provided under the MIT license

config.template.docker.yaml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
# MySQL server details
2+
# server: domain or IP of MySQL server
3+
# database: a MySQL database that the user specified has read/write access to
4+
# user: username to authenticate as
5+
# password: password for user
6+
mysql:
7+
server: '${MYSQL_HOST}'
8+
port: ${MYSQL_PORT}
9+
database: '${MYSQL_DATABASE}'
10+
user: '${MYSQL_USER}'
11+
password: '${MYSQL_PASSWORD}'
12+
pool-size: 10
13+
14+
# Define IPs/ports to listen on
15+
# Each entry MUST define ip and port (ip can be '' to bind all available addresses)
16+
# Each entry should set http, https, and/or io to true to listen for the corresponding
17+
# service on that port. http/io and https/io can be combined, but if http and https
18+
# are both specified, only https will be bound to that port.
19+
#
20+
# If you don't specify a url, the url io.domain:port or https.domain:port will be assumed
21+
# for non-ssl and ssl websockets, respectively. You can override this by specifying the
22+
# url for a websocket listener.
23+
listen:
24+
# Default HTTP server - default interface, port 8080
25+
- ip: ''
26+
port: ${ROOT_PORT}
27+
http: true
28+
io: true
29+
url: ${ROOT_URL}
30+
# Uncomment below to enable HTTPS/SSL websockets
31+
# Note that you must also set https->enabled = true in the https definition
32+
# - ip: ''
33+
# port: 8443
34+
# https: true
35+
# io: true
36+
# Default Socket.IO server - default interface, port 1337
37+
# - ip: ''
38+
# port: ${IO_ROOT_PORT}
39+
# io: true
40+
# Example of how to bind an extra port to HTTP and Socket.IO
41+
# - ip: ''
42+
# port: 8081
43+
# http: true
44+
# io: true
45+
# url: 'http://my-other-thing.site.com:8081'
46+
47+
# HTTP server details
48+
http:
49+
# Even though you may specify multiple ports to listen on for HTTP above,
50+
# one port must be specified as default for the purposes of generating
51+
# links with the appropriate port
52+
default-port: ${ROOT_PORT}
53+
# Specifies the root domain for cookies. If you have multiple domains
54+
# e.g. a.example.com and b.example.com, the root domain is example.com
55+
root-domain: '${ROOT_DOMAIN}'
56+
# Specify alternate domains/hosts that are allowed to set the login cookie
57+
# Leave out the http://
58+
alt-domains:
59+
- '127.0.0.1'
60+
# Use express-minify to minify CSS and Javascript
61+
minify: false
62+
# Max-Age for caching. Value should be an integer in milliseconds or a string accepted by
63+
# the `ms` module. Set to 0 to disable caching.
64+
max-age: '7d'
65+
# Set to false to disable gzip compression
66+
gzip: true
67+
# Customize the threshold byte size for applying gzip
68+
gzip-threshold: 1024
69+
# Secret used for signed cookies. Can be anything, but make it unique and hard to guess
70+
cookie-secret: '${COOKIE_SECRET}'
71+
index:
72+
# Maximum number of channels to display on the index page public channel list
73+
max-entries: 50
74+
# Configure trusted proxy addresses to map X-Forwarded-For to the client IP.
75+
# See also: https://github.com/jshttp/proxy-addr
76+
trust-proxies:
77+
- loopback
78+
- 103.21.244.0/22 # Cloudflare
79+
- 103.22.200.0/22
80+
- 103.31.4.0/22
81+
- 104.16.0.0/13
82+
- 104.24.0.0/14
83+
- 108.162.192.0/18
84+
- 131.0.72.0/22
85+
- 141.101.64.0/18
86+
- 162.158.0.0/15
87+
- 172.64.0.0/13
88+
- 173.245.48.0/20
89+
- 188.114.96.0/20
90+
- 190.93.240.0/20
91+
- 197.234.240.0/22
92+
- 198.41.128.0/17
93+
- 2400:cb00::/32
94+
- 2606:4700::/32
95+
- 2803:f800::/32
96+
- 2405:b500::/32
97+
- 2405:8100::/32
98+
- 2a06:98c0::/29
99+
- 2c0f:f248::/32
100+
- ${IMMEDIATE_PROXY}
101+
102+
# HTTPS server details
103+
https:
104+
enabled: ${HTTPS_ENABLED}
105+
# Even though you may specify multiple ports to listen on for HTTPS above,
106+
# one port must be specified as default for the purposes of generating
107+
# links with the appropriate port
108+
default-port: 8443
109+
domain: '${ROOT_URL}'
110+
keyfile: 'localhost.key'
111+
passphrase: ''
112+
certfile: 'localhost.cert'
113+
cafile: ''
114+
ciphers: 'HIGH:!DSS:!aNULL@STRENGTH'
115+
116+
# Page template values
117+
# title goes in the upper left corner, description goes in a <meta> tag
118+
html-template:
119+
title: '${SYNC_TITLE}'
120+
description: '${SYNC_DESCRIPTION}'
121+
122+
# Socket.IO server details
123+
io:
124+
# In most cases this will be the same as the http.domain.
125+
# However, if your HTTP traffic is going through a proxy (e.g. cloudflare)
126+
# you will want to set up a passthrough domain for socket.io.
127+
# If the root of this domain is not the same as the root of your HTTP domain
128+
# (or HTTPS if SSL is enabled), logins won't work.
129+
domain: '${IO_ROOT_URL}'
130+
# Even though you may specify multiple ports to listen on for HTTP above,
131+
# one port must be specified as default for the purposes of generating
132+
# links with the appropriate port
133+
default-port: ${IO_ROOT_PORT}
134+
# limit the number of concurrent socket connections per IP address
135+
ip-connection-limit: 10
136+
cors:
137+
# Additional origins to allow socket connections from (io.domain and
138+
# https.domain are included implicitly).
139+
allowed-origins: []
140+
141+
# YouTube v3 API key
142+
# 1. Go to https://console.developers.google.com/, create a new "project" (or choose an existing one)
143+
# 2. Make sure the YouTube Data v3 API is "enabled" for your project: https://console.developers.google.com/apis/library/youtube.googleapis.com
144+
# 3. Go to "Credentials" on the sidebar of https://console.developers.google.com/, click "Create credentials" and choose type "API key"
145+
# 4. Optionally restrict the key for security, or just copy the key.
146+
# 5. Test your key (may take a few minutes to become active):
147+
#
148+
# $ export YOUTUBE_API_KEY="your key here"
149+
# $ curl "https://www.googleapis.com/youtube/v3/search?key=$YOUTUBE_API_KEY&part=id&maxResults=1&q=test+video&type=video"
150+
youtube-v3-key: '${YOUTUBE_KEY}'
151+
# Limit for the number of channels a user can register
152+
max-channels-per-user: 5
153+
# Limit for the number of accounts an IP address can register
154+
max-accounts-per-ip: 5
155+
# Minimum number of seconds between guest logins from the same IP
156+
guest-login-delay: 60
157+
158+
# Allows you to customize the path divider. The /r/ in http://localhost/r/yourchannel
159+
# Acceptable characters are a-z A-Z 0-9 _ and -
160+
channel-path: 'r'
161+
# Allows you to blacklist certain channels. Users will be automatically kicked
162+
# upon trying to join one.
163+
channel-blacklist: []
164+
# Minutes between saving channel state to disk
165+
channel-save-interval: 5
166+
167+
# Configure periodic clearing of old alias data
168+
aliases:
169+
# Interval (in milliseconds) between subsequent runs of clearing
170+
purge-interval: 3600000
171+
# Maximum age of an alias (in milliseconds) - default 1 month
172+
max-age: 2592000000
173+
174+
# Workaround for Vimeo blocking my domain
175+
vimeo-workaround: false
176+
177+
# Regular expressions for defining reserved user and channel names and page titles
178+
# The list of regular expressions will be joined with an OR, and compared without
179+
# case sensitivity.
180+
#
181+
# Default: reserve any name containing "admin[istrator]" or "owner" as a word
182+
# but only if it is separated by a dash or underscore (e.g. dadmin is not reserved
183+
# but d-admin is)
184+
reserved-names:
185+
usernames:
186+
- '^(.*?[-_])?admin(istrator)?([-_].*)?$'
187+
- '^(.*?[-_])?owner([-_].*)?$'
188+
channels:
189+
- '^(.*?[-_])?admin(istrator)?([-_].*)?$'
190+
- '^(.*?[-_])?owner([-_].*)?$'
191+
pagetitles: []
192+
193+
# Provide a contact list for the /contact page
194+
# Example:
195+
# contacts:
196+
# - name: 'my_name'
197+
# title: 'administrator
198+
# email: 'me@my.site'
199+
contacts: []
200+
201+
playlist:
202+
max-items: 4000
203+
# How often (in seconds), mediaUpdate packets are broadcast to clients
204+
update-interval: 5
205+
206+
# If set to true, when the ipThrottle and lastguestlogin rate limiters are cleared
207+
# periodically, the garbage collector will be invoked immediately.
208+
# The server must be invoked with node --expose-gc index.js for this to have any effect.
209+
aggressive-gc: false
210+
211+
# If you have ffmpeg installed, you can query metadata from raw files, allowing
212+
# server-synched raw file playback. This requires the following:
213+
# * ffmpeg must be installed on the server
214+
ffmpeg:
215+
enabled: true
216+
# Executable name for ffprobe if it is not "ffprobe". On Debian and Ubuntu (on which
217+
# libav is used rather than ffmpeg proper), this is "avprobe"
218+
ffprobe-exec: 'ffprobe'
219+
220+
link-domain-blacklist: []
221+
222+
# Drop root if started as root!!
223+
setuid:
224+
enabled: false
225+
group: 'users'
226+
user: 'user'
227+
# how long to wait in ms before changing uid/gid
228+
timeout: 15
229+
230+
# Allows for external services to access the system commandline
231+
# Useful for setups where stdin isn't available such as when using PM2
232+
service-socket:
233+
enabled: false
234+
socket: 'service.sock'
235+
236+
# Twitch Client ID for the data API (used for VOD lookups)
237+
# https://github.com/justintv/Twitch-API/blob/master/authentication.md#developer-setup
238+
twitch-client-id: '${TWITCH_CLIENT_ID}'
239+
240+
poll:
241+
max-options: 50

container-install.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
apk update
4+
apk add build-base python git nodejs nodejs-npm mysql mysql-client curl gettext ffmpeg
5+
npm install npm@latest -g
6+
npm install
7+
npm run build-server
8+
9+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"cookie-parser": "^1.4.5",
2020
"create-error": "^0.3.1",
2121
"csrf": "^3.1.0",
22-
"cytubefilters": "github:calzoneman/cytubefilters#c67b2dab2dc5cc5ed11018819f71273d0f8a1bf5",
22+
"cytubefilters": "git://github.com/davidsiaw/cytubefilters",
2323
"express": "^4.17.1",
2424
"express-minify": "^1.0.0",
2525
"json-typecheck": "^0.1.3",

0 commit comments

Comments
 (0)