diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..780426b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:10-buster-slim as build-stage + +WORKDIR /app + +COPY package.json . +RUN yarn install --pure-lockfile \ + && yarn cache clean + +COPY . . + +RUN yarn run build + + +FROM nginx as production-stage +RUN mkdir /app +COPY --from=build-stage /app/dist /app +COPY nginx.conf /etc/nginx/nginx.conf diff --git a/README.md b/README.md index 93eae3e..6465eab 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ $ npm run serve ## Build for production ``` -$ yarn install --pure-lockfile -$ npm run build +# sudo docker build . -t joinpeertube +# docker run -it --rm -p 8080:80 --name joinpeertube joinpeertube ``` ## Update translations diff --git a/generate-instances-json.py b/generate-instances-json.py index 763a77a..769fbcb 100644 --- a/generate-instances-json.py +++ b/generate-instances-json.py @@ -8,27 +8,30 @@ instance_list = ['peertube.social', 'tube.tchncs.de', 'vidcommons.org', 'video.d json_list = [] id = 0 for i in instance_list: - r = requests.get('https://' + i + '/api/v1/config') - jsonres = r.json() + config_json = requests.get('https://' + i + '/api/v1/config').json() + about = requests.get('https://' + i + '/api/v1/config/about') + stats = requests.get('https://' + i + '/api/v1/server/stats') + about_json = about.json() + stats_json = stats.json() data = { "id": id, "host": i, - "name": jsonres['instance']['name'], - "shortDescription": r.json()['instance']['shortDescription'], - "version": jsonres['serverVersion'], - "signupAllowed": jsonres['signup']['allowed'], - "userVideoQuota": jsonres['user']['videoQuota'], - "categories": [], - "languages": [], - "autoBlacklistUserVideosEnabled": False, - "defaultNSFWPolicy": jsonres['instance']['defaultNSFWPolicy'], - "isNSFW": jsonres['instance']['isNSFW'], - "totalUsers": None, - "totalVideos": None, - "totalLocalVideos": None, - "totalInstanceFollowers": None, - "totalInstanceFollowing": None, + "name": config_json['instance']['name'], + "shortDescription": config_json['instance']['shortDescription'], + "version": config_json['serverVersion'], + "signupAllowed": config_json['signup']['allowed'], + "userVideoQuota": config_json['user']['videoQuota'], + "categories": about_json['instance']['categories'], + "languages": about_json['instance']['languages'], + "autoBlacklistUserVideosEnabled": config_json['autoBlacklist']['videos']['ofUsers']['enabled'], + "defaultNSFWPolicy": config_json['instance']['defaultNSFWPolicy'], + "isNSFW": config_json['instance']['isNSFW'], + "totalUsers": stats_json['totalUsers'], + "totalVideos": stats_json['totalVideos'], + "totalLocalVideos": stats_json['totalLocalVideos'], + "totalInstanceFollowers": stats_json['totalInstanceFollowers'], + "totalInstanceFollowing": stats_json['totalInstanceFollowing'], "health": None, "createdAt": None } diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..ba372e2 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,31 @@ +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + location / { + root /app; + index index.html; + try_files $uri $uri/ /index.html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +} + diff --git a/public/instances.json b/public/instances.json index 6bf4938..3de7dbc 100644 --- a/public/instances.json +++ b/public/instances.json @@ -1,67 +1,183 @@ { - "total": 3, - "data": [{ - "id": -1, - "host": "peertube.social", - "name": "Peertube.social", - "shortDescription": "Peertube instance for leftist and non-commercial content. Unlimited uploads (up to 500 MB per day)", - "version": "2.0.0", - "signupAllowed": false, - "userVideoQuota": -1, - "categories": [], - "languages": [], - "autoBlacklistUserVideosEnabled": false, - "defaultNSFWPolicy": "do_not_list", - "isNSFW": false, - "totalUsers": null, - "totalVideos": null, - "totalLocalVideos": null, - "totalInstanceFollowers": null, - "totalInstanceFollowing": null, - "health": null, - "createdAt": null - }, - { - "id": -1, - "host": "tube.tchncs.de", - "name": "tchncs", - "shortDescription": "PeerTube instance for your unique Vlogs and what not. 😉", - "version": "2.0.0", - "signupAllowed": false, - "userVideoQuota": -1, - "categories": [], - "languages": [], - "autoBlacklistUserVideosEnabled": false, - "defaultNSFWPolicy": "do_not_list", - "isNSFW": false, - "totalUsers": null, - "totalVideos": null, - "totalLocalVideos": null, - "totalInstanceFollowers": null, - "totalInstanceFollowing": null, - "health": null, - "createdAt": null - }, - { - "id": -1, - "host": "vidcommons.org", - "name": "The VidCommons Project", - "shortDescription": "A PeerTube instance dedicated to media licensed under the Creative Commons and Public Domain.", - "version": "2.0.0", - "signupAllowed": false, - "userVideoQuota": -1, - "categories": [], - "languages": [], - "autoBlacklistUserVideosEnabled": false, - "defaultNSFWPolicy": "do_not_list", - "isNSFW": false, - "totalUsers": null, - "totalVideos": null, - "totalLocalVideos": null, - "totalInstanceFollowers": null, - "totalInstanceFollowing": null, - "health": null, - "createdAt": null - } - ] + "total": 6, + "data": [ + { + "id": 0, + "host": "peertube.social", + "name": "Peertube.social", + "shortDescription": "Peertube instance for leftist and non-commercial content. Unlimited uploads (up to 500 MB per day)", + "version": "2.0.0", + "signupAllowed": false, + "userVideoQuota": -1, + "categories": [], + "languages": [ + "es", + "de", + "en", + "sv", + "da", + "no", + "eo" + ], + "autoBlacklistUserVideosEnabled": true, + "defaultNSFWPolicy": "do_not_list", + "isNSFW": false, + "totalUsers": 1977, + "totalVideos": 96066, + "totalLocalVideos": 4686, + "totalInstanceFollowers": 75, + "totalInstanceFollowing": 307, + "health": null, + "createdAt": null + }, + { + "id": 1, + "host": "tube.tchncs.de", + "name": "tchncs", + "shortDescription": "PeerTube instance for your unique Vlogs and what not. \ud83d\ude09", + "version": "2.0.0", + "signupAllowed": false, + "userVideoQuota": -1, + "categories": [ + 10, + 15, + 8, + 12, + 14, + 13, + 4, + 11 + ], + "languages": [ + "en", + "de" + ], + "autoBlacklistUserVideosEnabled": true, + "defaultNSFWPolicy": "blur", + "isNSFW": false, + "totalUsers": 230, + "totalVideos": 4129, + "totalLocalVideos": 573, + "totalInstanceFollowers": 84, + "totalInstanceFollowing": 6, + "health": null, + "createdAt": null + }, + { + "id": 2, + "host": "vidcommons.org", + "name": "The VidCommons Project", + "shortDescription": "A PeerTube instance dedicated to media licensed under the Creative Commons and Public Domain.", + "version": "2.0.0", + "signupAllowed": false, + "userVideoQuota": -1, + "categories": [ + 13, + 10, + 2, + 9, + 15 + ], + "languages": [ + "en" + ], + "autoBlacklistUserVideosEnabled": false, + "defaultNSFWPolicy": "display", + "isNSFW": false, + "totalUsers": 7, + "totalVideos": 260, + "totalLocalVideos": 140, + "totalInstanceFollowers": 88, + "totalInstanceFollowing": 0, + "health": null, + "createdAt": null + }, + { + "id": 3, + "host": "video.deadsuperhero.com", + "name": "DeadSuperHero Video", + "shortDescription": "A federated PeerTube instance of all of Sean Tilley's video projects.", + "version": "2.0.0", + "signupAllowed": false, + "userVideoQuota": -1, + "categories": [ + 8, + 10 + ], + "languages": [ + "en" + ], + "autoBlacklistUserVideosEnabled": false, + "defaultNSFWPolicy": "display", + "isNSFW": false, + "totalUsers": 4, + "totalVideos": 66880, + "totalLocalVideos": 39, + "totalInstanceFollowers": 134, + "totalInstanceFollowing": 61, + "health": null, + "createdAt": null + }, + { + "id": 4, + "host": "diode.zone", + "name": "Diode Zone", + "shortDescription": "Diode Zone is a friendly place for original content with a focus on creativity and electronics!", + "version": "2.0.0", + "signupAllowed": true, + "userVideoQuota": -1, + "categories": [ + 15, + 12, + 8, + 16 + ], + "languages": [ + "en" + ], + "autoBlacklistUserVideosEnabled": false, + "defaultNSFWPolicy": "blur", + "isNSFW": false, + "totalUsers": 342, + "totalVideos": 4435, + "totalLocalVideos": 1146, + "totalInstanceFollowers": 89, + "totalInstanceFollowing": 6, + "health": null, + "createdAt": null + }, + { + "id": 5, + "host": "share.tube", + "name": "ShareTUBE [a PeerTube Fediverse Server]", + "shortDescription": "A peertube instance advocating for sharing Creative Commons videos utilizing open source platforms. Share \u2014 thru Creative Commons & the nature of federation that automatically shares to other servers for tube enjoyment & inspiration.", + "version": "2.0.0", + "signupAllowed": false, + "userVideoQuota": 0, + "categories": [ + 4, + 7, + 15, + 10, + 13, + 12, + 1, + 11, + 8 + ], + "languages": [ + "en" + ], + "autoBlacklistUserVideosEnabled": false, + "defaultNSFWPolicy": "blur", + "isNSFW": false, + "totalUsers": 60, + "totalVideos": 4062, + "totalLocalVideos": 615, + "totalInstanceFollowers": 111, + "totalInstanceFollowing": 6, + "health": null, + "createdAt": null + } + ] }