Browse Source

initial commit

master
Yasuhiro Yamaguchi 5 years ago
commit
1862754ddb
  1. 1
      .gitignore
  2. 15
      README.md
  3. 11
      config/config.yml
  4. 4
      config/migrate-scripts/migrate-db-17cf077.sh
  5. 7
      config/migrate-scripts/migrate-db-1c8075c.sh
  6. 19
      config/migrate-scripts/migrate-db-1eca969.sh
  7. 4
      config/migrate-scripts/migrate-db-30e6d29.sh
  8. 5
      config/migrate-scripts/migrate-db-3646395.sh
  9. 3
      config/migrate-scripts/migrate-db-3bcb98e.sh
  10. 3
      config/migrate-scripts/migrate-db-52cb239.sh
  11. 4
      config/migrate-scripts/migrate-db-6e51189.sh
  12. 3
      config/migrate-scripts/migrate-db-701b5ea.sh
  13. 3
      config/migrate-scripts/migrate-db-88b7097.sh
  14. 5
      config/migrate-scripts/migrate-db-8e884fe.sh
  15. 12
      config/sql/annotations.sql
  16. 30
      config/sql/channel_videos.sql
  17. 25
      config/sql/channels.sql
  18. 22
      config/sql/nonces.sql
  19. 19
      config/sql/playlist_videos.sql
  20. 29
      config/sql/playlists.sql
  21. 23
      config/sql/session_ids.sql
  22. 29
      config/sql/users.sql
  23. 23
      config/sql/videos.sql
  24. 51
      docker-compose.yml
  25. 16
      docker/init-invidious-db.sh

1
.gitignore

@ -0,0 +1 @@
.env

15
README.md

@ -0,0 +1,15 @@
invidious-docker
================
Docker configs for [Invidious](https://github.com/iv-org/invidious).
### Installation
```
$ cat << EOF > .env
INVIDIOUS_HTTP_PORT=8080
INVIDIOUS_ADMIN_USER=admin
EOF
$ docker-compose up -d
```

11
config/config.yml

@ -0,0 +1,11 @@
channel_threads: 1
feed_threads: 1
db:
user: kemal
password: kemal
host: localhost
port: 5432
dbname: invidious
full_refresh: false
https_only: false
domain:

4
config/migrate-scripts/migrate-db-17cf077.sh

@ -0,0 +1,4 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channels ADD COLUMN subscribed bool;"
psql invidious kemal -c "UPDATE channels SET subscribed = false;"

7
config/migrate-scripts/migrate-db-1c8075c.sh

@ -0,0 +1,7 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channel_videos DROP COLUMN live_now CASCADE"
psql invidious kemal -c "ALTER TABLE channel_videos DROP COLUMN premiere_timestamp CASCADE"
psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN live_now bool"
psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN premiere_timestamp timestamptz"

19
config/migrate-scripts/migrate-db-1eca969.sh

@ -0,0 +1,19 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN title CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN views CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN likes CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN dislikes CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN wilson_score CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN published CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN description CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN language CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN author CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN ucid CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN allowed_regions CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN is_family_friendly CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN genre CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN genre_url CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN license CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN sub_count_text CASCADE"
psql invidious kemal -c "ALTER TABLE videos DROP COLUMN author_thumbnail CASCADE"

4
config/migrate-scripts/migrate-db-30e6d29.sh

@ -0,0 +1,4 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channels ADD COLUMN deleted bool;"
psql invidious kemal -c "UPDATE channels SET deleted = false;"

5
config/migrate-scripts/migrate-db-3646395.sh

@ -0,0 +1,5 @@
#!/bin/sh
psql invidious kemal < config/sql/session_ids.sql
psql invidious kemal -c "INSERT INTO session_ids (SELECT unnest(id), email, CURRENT_TIMESTAMP FROM users) ON CONFLICT (id) DO NOTHING"
psql invidious kemal -c "ALTER TABLE users DROP COLUMN id"

3
config/migrate-scripts/migrate-db-3bcb98e.sh

@ -0,0 +1,3 @@
#!/bin/sh
psql invidious kemal < config/sql/annotations.sql

3
config/migrate-scripts/migrate-db-52cb239.sh

@ -0,0 +1,3 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN views bigint;"

4
config/migrate-scripts/migrate-db-6e51189.sh

@ -0,0 +1,4 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN live_now bool;"
psql invidious kemal -c "UPDATE channel_videos SET live_now = false;"

3
config/migrate-scripts/migrate-db-701b5ea.sh

@ -0,0 +1,3 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE users ADD COLUMN feed_needs_update boolean"

3
config/migrate-scripts/migrate-db-88b7097.sh

@ -0,0 +1,3 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channel_videos ADD COLUMN premiere_timestamp timestamptz;"

5
config/migrate-scripts/migrate-db-8e884fe.sh

@ -0,0 +1,5 @@
#!/bin/sh
psql invidious kemal -c "ALTER TABLE channels DROP COLUMN subscribed"
psql invidious kemal -c "ALTER TABLE channels ADD COLUMN subscribed timestamptz"
psql invidious kemal -c "UPDATE channels SET subscribed = '2019-01-01 00:00:00+00'"

12
config/sql/annotations.sql

@ -0,0 +1,12 @@
-- Table: public.annotations
-- DROP TABLE public.annotations;
CREATE TABLE public.annotations
(
id text NOT NULL,
annotations xml,
CONSTRAINT annotations_id_key UNIQUE (id)
);
GRANT ALL ON TABLE public.annotations TO kemal;

30
config/sql/channel_videos.sql

@ -0,0 +1,30 @@
-- Table: public.channel_videos
-- DROP TABLE public.channel_videos;
CREATE TABLE public.channel_videos
(
id text NOT NULL,
title text,
published timestamp with time zone,
updated timestamp with time zone,
ucid text,
author text,
length_seconds integer,
live_now boolean,
premiere_timestamp timestamp with time zone,
views bigint,
CONSTRAINT channel_videos_id_key UNIQUE (id)
);
GRANT ALL ON TABLE public.channel_videos TO kemal;
-- Index: public.channel_videos_ucid_idx
-- DROP INDEX public.channel_videos_ucid_idx;
CREATE INDEX channel_videos_ucid_idx
ON public.channel_videos
USING btree
(ucid COLLATE pg_catalog."default");

25
config/sql/channels.sql

@ -0,0 +1,25 @@
-- Table: public.channels
-- DROP TABLE public.channels;
CREATE TABLE public.channels
(
id text NOT NULL,
author text,
updated timestamp with time zone,
deleted boolean,
subscribed timestamp with time zone,
CONSTRAINT channels_id_key UNIQUE (id)
);
GRANT ALL ON TABLE public.channels TO kemal;
-- Index: public.channels_id_idx
-- DROP INDEX public.channels_id_idx;
CREATE INDEX channels_id_idx
ON public.channels
USING btree
(id COLLATE pg_catalog."default");

22
config/sql/nonces.sql

@ -0,0 +1,22 @@
-- Table: public.nonces
-- DROP TABLE public.nonces;
CREATE TABLE public.nonces
(
nonce text,
expire timestamp with time zone,
CONSTRAINT nonces_id_key UNIQUE (nonce)
);
GRANT ALL ON TABLE public.nonces TO kemal;
-- Index: public.nonces_nonce_idx
-- DROP INDEX public.nonces_nonce_idx;
CREATE INDEX nonces_nonce_idx
ON public.nonces
USING btree
(nonce COLLATE pg_catalog."default");

19
config/sql/playlist_videos.sql

@ -0,0 +1,19 @@
-- Table: public.playlist_videos
-- DROP TABLE public.playlist_videos;
CREATE TABLE playlist_videos
(
title text,
id text,
author text,
ucid text,
length_seconds integer,
published timestamptz,
plid text references playlists(id),
index int8,
live_now boolean,
PRIMARY KEY (index,plid)
);
GRANT ALL ON TABLE public.playlist_videos TO kemal;

29
config/sql/playlists.sql

@ -0,0 +1,29 @@
-- Type: public.privacy
-- DROP TYPE public.privacy;
CREATE TYPE public.privacy AS ENUM
(
'Public',
'Unlisted',
'Private'
);
-- Table: public.playlists
-- DROP TABLE public.playlists;
CREATE TABLE public.playlists
(
title text,
id text primary key,
author text,
description text,
video_count integer,
created timestamptz,
updated timestamptz,
privacy privacy,
index int8[]
);
GRANT ALL ON public.playlists TO kemal;

23
config/sql/session_ids.sql

@ -0,0 +1,23 @@
-- Table: public.session_ids
-- DROP TABLE public.session_ids;
CREATE TABLE public.session_ids
(
id text NOT NULL,
email text,
issued timestamp with time zone,
CONSTRAINT session_ids_pkey PRIMARY KEY (id)
);
GRANT ALL ON TABLE public.session_ids TO kemal;
-- Index: public.session_ids_id_idx
-- DROP INDEX public.session_ids_id_idx;
CREATE INDEX session_ids_id_idx
ON public.session_ids
USING btree
(id COLLATE pg_catalog."default");

29
config/sql/users.sql

@ -0,0 +1,29 @@
-- Table: public.users
-- DROP TABLE public.users;
CREATE TABLE public.users
(
updated timestamp with time zone,
notifications text[],
subscriptions text[],
email text NOT NULL,
preferences text,
password text,
token text,
watched text[],
feed_needs_update boolean,
CONSTRAINT users_email_key UNIQUE (email)
);
GRANT ALL ON TABLE public.users TO kemal;
-- Index: public.email_unique_idx
-- DROP INDEX public.email_unique_idx;
CREATE UNIQUE INDEX email_unique_idx
ON public.users
USING btree
(lower(email) COLLATE pg_catalog."default");

23
config/sql/videos.sql

@ -0,0 +1,23 @@
-- Table: public.videos
-- DROP TABLE public.videos;
CREATE TABLE public.videos
(
id text NOT NULL,
info text,
updated timestamp with time zone,
CONSTRAINT videos_pkey PRIMARY KEY (id)
);
GRANT ALL ON TABLE public.videos TO kemal;
-- Index: public.id_idx
-- DROP INDEX public.id_idx;
CREATE UNIQUE INDEX id_idx
ON public.videos
USING btree
(id COLLATE pg_catalog."default");

51
docker-compose.yml

@ -0,0 +1,51 @@
version: '3'
services:
waitfordb:
image: dadarek/wait-for-dependencies
depends_on:
- postgres
command: postgres:5432
postgres:
image: postgres:11
restart: always
volumes:
- postgresdata:/var/lib/postgresql/data
- ./config/sql:/config/sql
- ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh
environment:
POSTGRES_DB: invidious
POSTGRES_PASSWORD: kemal
POSTGRES_USER: kemal
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
invidious:
image: 1337kavin/invidious
depends_on:
- postgres
- waitfordb
restart: always
ports:
- "${INVIDIOUS_HTTP_PORT}:3000"
environment:
INVIDIOUS_CONFIG: |
channel_threads: 1
check_tables: true
feed_threads: 1
db:
user: kemal
password: kemal
host: postgres
port: 5432
dbname: invidious
full_refresh: false
https_only: false
domain: iv.altescy.jp
registration_enabled: false
admins: ["${INVIDIOUS_ADMIN_USER}"]
depends_on:
- postgres
volumes:
postgresdata:

16
docker/init-invidious-db.sh

@ -0,0 +1,16 @@
#!/bin/bash
set -eou pipefail
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER postgres;
EOSQL
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/channels.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/videos.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/channel_videos.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/users.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/session_ids.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/nonces.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/annotations.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlists.sql
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlist_videos.sql
Loading…
Cancel
Save