Compare commits

...

5 Commits

Author SHA1 Message Date
wait-what
ec6a3f6e5a im bored now 2024-04-23 00:57:50 +03:00
wait-what
16f79f9ff2 revert original config file and update explanation 2024-04-23 00:45:59 +03:00
wait-what
74c7e7d051 dockerize the whole thing 2024-04-23 00:38:01 +03:00
wait-what
7d2776584b fix docker image 2024-04-23 00:37:54 +03:00
wait-what
8d8b098d86 improve docker image 2024-04-23 00:37:39 +03:00
18 changed files with 1129 additions and 317 deletions

View File

@ -3,8 +3,13 @@
.git
.gitignore
node_modules
invidious-source
json.sqlite
*.md
docker-compose.yml
Dockerfile
/docker-compose.yml
/Dockerfile
/config.json
/january
/pokevidious
/p
/t
/sdk

View File

@ -2,10 +2,14 @@
## docker build -t poketube .
## To run the image, run:
## docker run -d -p 6003:6003 poketube
## docker run -p 6003:6003 -v ./config.json:/poketube/config.json:ro poketube
## but preferably, use the docker-compose.yml file
# Base (Debian)
FROM debian
# Base
FROM node:16-alpine
# Install dependencies
RUN apk add --no-cache git build-base python3
# Set Work Directory
WORKDIR /poketube
@ -14,21 +18,8 @@ COPY . /poketube
# Expose Ports
EXPOSE 6003
# Install Requirements
RUN apt-get update && apt-get -y install \
libcurl4-openssl-dev make g++ ca-certificates curl gnupg
# Install NodeJS v18
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get -y install nodejs npm
# Install Packages
# Install Dependencies
RUN npm install
# Run
CMD npm start
# Start the app
CMD ["npm", "start"]

View File

@ -3,15 +3,15 @@
"invapi": "https://invid-api.poketube.fun/api/v1",
"dislikes": "https://returnyoutubedislikeapi.com/votes?videoId=",
"invchannel": "https://invid-api.poketube.fun/api/v1",
"p_url":"https://p.poketube.fun",
"p_url": "https://p.poketube.fun",
"media_proxy": "https://image-proxy.poketube.fun",
"videourl":"https://eu-proxy.poketube.fun",
"email_main_url":"https://email-server.poketube.fun",
"mastodon_client_url":"https://fediverse.poketube.fun",
"libreoffice_online_url":"https://office.poketube.fun",
"videourl": "https://eu-proxy.poketube.fun",
"email_main_url": "https://email-server.poketube.fun",
"mastodon_client_url": "https://fediverse.poketube.fun",
"libreoffice_online_url": "https://office.poketube.fun",
"cacher_max_age": "864000",
"enablealwayshttps": false,
"proxylocation":"USA",
"proxylocation": "USA",
"t_url": "https://t.poketube.fun/",
"server_port": "6003"
}
}

View File

@ -1,9 +1,111 @@
# To run, please do either docker compose up -d (for docker's own version) or docker-compose up -d (for your OSes package managers verison)
# To run this entire stack (contains all services):
# 1. Verify you have docker and docker-compose
# 2. Make sure this repository is cloned recursively (check if the `pokevidious` folder has stuff in it)
# 3. Proceed either to Section A or Section B
# Section A : Local development
# 1. Add this to your hosts file /etc/hosts (Linux) or C:\Windows\System32\drivers\etc\hosts (Windows)
#
# 127.0.0.1 poketube.test image-proxy.poketube.test eu-proxy.poketube.test p.poketube.test
#
# 2. Run `docker-compose up -d` or `docker compose up -d` (notice the dash)
# 3. Visit `http://poketube.test` in your browser
# Section B : Production
# 3. Adjust domains in `docker/Caddyfile` and `docker/config.json`
# 3.1 DO NOT touch tubeApi, invapi, invchannel, videourl in `docker/config.json` unless you know what you are doing
# 3.2 As for the others, make sure they're all https in both files
# 3.2 You don't need to touch the other config files unless you know what you are doing
# 4. Run `docker-compose up -d` or `docker compose up -d` (notice the dash)
# 5. Visit your domain in your browser
services:
poketube:
image: quay.io/sudovanilla/poketube
poketube: # port 6003
# image: quay.io/sudovanilla/poketube
build:
context: .
dockerfile: Dockerfile
depends_on:
- invidious
- lighttube
- january
restart: unless-stopped
volumes:
- ./config.json:/poketube/config.json
- ./docker/poke.json:/poketube/config.json:ro
# lighttube - tubeApi
lighttube: # port 80
image: docker.io/kuylar/lighttube:20220711
depends_on:
- mongo
restart: unless-stopped
volumes:
- ./docker/lighttube.yaml:/etc/lighttube.yml:ro
mongo: # port 27017
image: docker.io/mongo:latest
env_file: ./docker/mongo.env
restart: unless-stopped
volumes:
- ./docker/data/mongo:/data/db
# invidious - invapi, invchannel and videourl
invidious: # port 3000
image: quay.io/invidious/invidious:latest
# build:
# context: pokevidious
# dockerfile: docker/Dockerfile
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
deploy:
replicas: 2 # Adjust number depending on server load
volumes:
- ./docker/invidious.yaml:/invidious/config/config.yml:ro
postgres: # port 5432
image: docker.io/library/postgres:14
env_file: ./docker/postgres.env
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER"]
interval: 10s
timeout: 5s
retries: 10
volumes:
- ./docker/data/postgres:/var/lib/postgresql/data
- ./pokevidious/config/sql:/config/sql:ro
- ./pokevidious/docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh:ro
# january - media_proxy
january: # port 7000
# image: ghcr.io/revoltchat/january:latest
build:
context: january
dockerfile: Dockerfile
restart: unless-stopped
# p / pproxy - some kind of proxy idk
pproxy: # port 6014
build:
context: p
dockerfile: Dockerfile
volumes:
- ./docker/pproxy.json:/pproxy/whitelist.json:ro
restart: unless-stopped
# caddy - reverse proxy to connect everything together
caddy: # exposed ports 80, 443 / 8090
image: docker.io/caddy:latest
restart: unless-stopped
volumes:
- ./docker/Caddyfile:/etc/caddy/Caddyfile:ro
- ./docker/data/caddy:/data
ports:
- "6003:6003"
# Notice this is the only service with ports exposed
- 80:80
- 443:443
# If you are running another proxy on the host and the ports are taken
# ... use this instead, and proxy the relevant domains to 127.0.0.1:8090
# Be aware that browsers will refuse
# - 127.0.0.1:8090:80

1
docker/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/data

23
docker/Caddyfile Normal file
View File

@ -0,0 +1,23 @@
# You may want to remove the http:// part for automatic HTTPS
# This is needed here because we're testing locally
http://poketube.test {
reverse_proxy poketube:6003
}
http://image-proxy.poketube.test {
reverse_proxy january:7000
}
http://eu-proxy.poketube.test {
@invidious {
path /videoplayback*
path /latest_version*
}
reverse_proxy @invidious invidious:3000
}
http://p.poketube.test {
reverse_proxy pproxy:6014
}

8
docker/invidious.yaml Normal file
View File

@ -0,0 +1,8 @@
db:
dbname: invidious
user: postgres
password: postgres
host: postgres
port: 5432
check_tables: true
hmac_key: ujZnZzcMoxg2pEjdV52c

8
docker/lighttube.yaml Normal file
View File

@ -0,0 +1,8 @@
Interface:
MessageOfTheDay: meow
Credentials:
UseCredentials: false
Sapisid:
Psid:
Database:
MongoConnectionString: mongodb://lighttube:lighttube@mongo:27017/

2
docker/mongo.env Normal file
View File

@ -0,0 +1,2 @@
MONGO_INITDB_ROOT_USERNAME=lighttube
MONGO_INITDB_ROOT_PASSWORD=lighttube

17
docker/poke.json Normal file
View File

@ -0,0 +1,17 @@
{
"tubeApi": "http://lighttube:80/api",
"invapi": "http://invidious:3000/api/v1",
"dislikes": "https://returnyoutubedislikeapi.com/votes?videoId=",
"invchannel": "http://invidious:3000/api/v1",
"p_url": "http://p.poketube.test",
"media_proxy": "http://image-proxy.poketube.test",
"videourl": "http://eu-proxy.poketube.test",
"email_main_url": "https://email-server.poketube.fun",
"mastodon_client_url": "https://fediverse.poketube.fun",
"libreoffice_online_url": "https://office.poketube.fun",
"cacher_max_age": "864000",
"enablealwayshttps": false,
"proxylocation": "USA",
"t_url": "https://t.poketube.fun/",
"server_port": "6003"
}

3
docker/postgres.env Normal file
View File

@ -0,0 +1,3 @@
POSTGRES_DB=invidious
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

32
docker/pproxy.json Normal file
View File

@ -0,0 +1,32 @@
[
"i.ytimg.com",
"yt3.googleusercontent.com",
"cdn.glitch.global",
"cdn.statically.io",
"site-assets.fontawesome.com",
"fonts.gstatic.com",
"cdn.jsdelivr.net",
"yt3.ggpht.com",
"tube.kuylar.dev",
"lh3.googleusercontent.com",
"is4-ssl.mzstatic.com",
"is2-ssl.mzstatic.com",
"is1-ssl.mzstatic.com",
"fonts.bunny.net",
"demo.matomo.org",
"is5-ssl.mzstatic.com",
"is3-ssl.mzstatic.com",
"twemoji.maxcdn.com",
"unpkg.com",
"lite.duckduckgo.com",
"youtube.com",
"returnyoutubedislikeapi.com",
"cdn.zptr.cc",
"inv.vern.cc",
"invidious.privacydev.net",
"inv.zzls.xyz",
"vid.puffyan.us",
"invidious.lidarshield.cloud",
"invidious.epicsite.xyz",
"invidious.esmailelbob.xyz"
]

980
january/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-web = "4.0"
actix-web = "4.4.1"
lazy_static = "1.4"
imagesize = "0.8"
reqwest = "0.11"

View File

@ -1,17 +1,19 @@
# Build Stage
FROM rustlang/rust:nightly-slim AS builder
FROM rustlang/rust:nightly-bullseye-slim AS builder
USER 0:0
WORKDIR /home/rust/src
RUN apt-get update && apt-get install -y libssl-dev pkg-config
RUN USER=root cargo new --bin january
WORKDIR /home/rust/src/january
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN apt-get update && apt-get install -y libssl-dev pkg-config && cargo install --locked --path .
RUN cargo install --locked --path .
# Bundle Stage
FROM debian:buster-slim
RUN apt-get update && apt-get install -y ca-certificates ffmpeg
FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y ca-certificates ffmpeg libssl-dev
COPY --from=builder /usr/local/cargo/bin/january ./
EXPOSE 7000
ENV JANUARY_HOST 0.0.0.0:7000

View File

@ -1,99 +1,21 @@
#################################################################################
# INSTALLERS #
# These images provide the dependencies required to build the other images. #
#################################################################################
# docker build -t pproxy .
# docker run -p 6003:6003 -v ./whitelist.json:/pproxy/whitelist.json:ro pproxy
FROM quay.io/almalinuxorg/9-base AS builder-installer
# Base
FROM node:18-alpine
# Needed for node 18+
# RUN dnf module --assumeyes enable nodejs
# Install dependencies
RUN apk add --no-cache git build-base python3
RUN --mount=type=cache,target=/var/cache/dnf \
dnf install --assumeyes --nodocs nodejs ca-certificates jq make gcc g++
# Set Work Directory
WORKDIR /pproxy
RUN npm install -g \
npm@$(curl "https://release-monitoring.org/api/v2/versions/?project_id=190206" | jq --raw-output '.stable_versions[0]')
# Install dependencies
# Honestly less effort this way
RUN yarn add express undici
# Copy files
COPY server.js .
# Runtime dependencies
FROM quay.io/almalinuxorg/9-base AS installer
COPY --from=quay.io/almalinuxorg/9-micro / /rpms
RUN --mount=type=cache,target=/var/cache/dnf \
dnf install --assumeyes \
--installroot /rpms \
--releasever=9 \
--setopt=install_weak_deps=false \
--nodocs \
nodejs ca-certificates
RUN dnf clean all \
--installroot /rpms
# Proxy + certbot
FROM quay.io/almalinuxorg/9-base AS proxy-installer
RUN dnf install epel-release --assumeyes
COPY --from=quay.io/almalinuxorg/9-micro / /rpms
RUN --mount=type=cache,target=/var/cache/dnf \
dnf install --assumeyes \
--installroot /rpms \
--releasever=9 \
--setopt=install_weak_deps=false \
--setopt=reposdir=/etc/yum.repos.d \
--nodocs \
nginx-core certbot python3-certbot-nginx
RUN dnf clean all \
--installroot /rpms
#################################################################################
# BUILDER #
#################################################################################
FROM builder-installer AS builder
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install --frozen-lockfile
# COPY ./ ./
COPY p/server.js ./
#################################################################################
# FINAL IMAGE #
#################################################################################
FROM quay.io/almalinuxorg/9-micro AS release-base
# Grab npm
COPY --from=installer /rpms /
# Grab site
COPY --from=builder /usr/src/app /app
WORKDIR /app
ENV NODE_ENV production
# Final image
FROM release-base as release
# EXPOSE 3000/tcp
CMD [ "node", "server.js" ]
# Final image with extras
FROM release-base AS release-aio
# Grab nginx and certbot
COPY --from=proxy-installer /rpms /
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
COPY nginx.conf.example /etc/nginx/conf.d/poketube.conf
# EXPOSE 80/tcp
# EXPOSE 443/tcp
ENTRYPOINT [ "/usr/bin/bash", "./entrypoint.sh" ]
# Entrypoint
CMD [ "node", "server.js" ]

View File

@ -1,41 +1,10 @@
const express = require("express");
const fetch = require("node-fetch");
// const fetch = require("node-fetch");
const { URL } = require("url");
const { Readable } = require("node:stream");
// Array of hostnames that will be proxied
const URL_WHITELIST = [
"i.ytimg.com",
"yt3.googleusercontent.com",
"cdn.glitch.global",
"cdn.statically.io",
"site-assets.fontawesome.com",
"fonts.gstatic.com",
"cdn.jsdelivr.net",
"yt3.ggpht.com",
"tube.kuylar.dev",
"lh3.googleusercontent.com",
"is4-ssl.mzstatic.com",
"is2-ssl.mzstatic.com",
"is1-ssl.mzstatic.com",
"fonts.bunny.net",
"demo.matomo.org",
"is5-ssl.mzstatic.com",
"is3-ssl.mzstatic.com",
"twemoji.maxcdn.com",
"unpkg.com",
"lite.duckduckgo.com",
"youtube.com",
"returnyoutubedislikeapi.com",
"cdn.zptr.cc",
"inv.vern.cc",
"invidious.privacydev.net",
"inv.zzls.xyz",
"vid.puffyan.us",
"invidious.lidarshield.cloud",
"invidious.epicsite.xyz",
"invidious.esmailelbob.xyz",
];
const URL_WHITELIST = require("./whitelist.json");
const app = express();
@ -162,6 +131,7 @@ const { fetch } = await import("undici")
});
app.get("/bangs", async (req, res) => {
const { fetch } = await import("undici")
let f = await fetch("https://lite.duckduckgo.com/lite/?q=" + req.query.q, {
method: req.method,

32
p/whitelist.json Normal file
View File

@ -0,0 +1,32 @@
[
"i.ytimg.com",
"yt3.googleusercontent.com",
"cdn.glitch.global",
"cdn.statically.io",
"site-assets.fontawesome.com",
"fonts.gstatic.com",
"cdn.jsdelivr.net",
"yt3.ggpht.com",
"tube.kuylar.dev",
"lh3.googleusercontent.com",
"is4-ssl.mzstatic.com",
"is2-ssl.mzstatic.com",
"is1-ssl.mzstatic.com",
"fonts.bunny.net",
"demo.matomo.org",
"is5-ssl.mzstatic.com",
"is3-ssl.mzstatic.com",
"twemoji.maxcdn.com",
"unpkg.com",
"lite.duckduckgo.com",
"youtube.com",
"returnyoutubedislikeapi.com",
"cdn.zptr.cc",
"inv.vern.cc",
"invidious.privacydev.net",
"inv.zzls.xyz",
"vid.puffyan.us",
"invidious.lidarshield.cloud",
"invidious.epicsite.xyz",
"invidious.esmailelbob.xyz"
]