From 3ad17d54f3655a4eaf17c3789ba402f599e673fe Mon Sep 17 00:00:00 2001 From: Sumit Khanna Date: Tue, 27 Apr 2021 22:41:11 -0400 Subject: [PATCH] Configuration fixes for Docker and docker-compose --- docker-compose.yml | 35 ++++++++++++++++------------------- docker/Dockerfile | 22 +++++++++++++++++++++- docker/init-invidious-db.sh | 4 ---- docker/startup | 26 ++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 docker/startup diff --git a/docker-compose.yml b/docker-compose.yml index bc292c53..febd796d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,12 +5,10 @@ services: restart: unless-stopped 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 + POSTGRES_DB: invidiousdb + POSTGRES_PASSWORD: R3p1aceW1thStr0ngPa33word + POSTGRES_USER: invidious healthcheck: test: ["CMD", "pg_isready", "-U", "postgres"] invidious: @@ -21,20 +19,19 @@ services: ports: - "127.0.0.1:3000:3000" environment: - # Adapted from ./config/config.yml - 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: + POSTGRES_USER: invidious + POSTGRES_PASS: R3p1aceW1thStr0ngPa33word + POSTGRES_HOST: postgres + POSTGRES_DB: invidiousdb + POSTGRES_PORT: 5432 + INVIDIOUS_DOMAIN: localhost + INVIDIOUS_REGISTRATION_ENABLED: "true" + INVIDIOUS_DISABLE_PROXY: "false" + INVIDIOUS_HTTPS_ONLY: "false" + INVIDIOUS_FULL_REFRESH: "false" + INVIDIOUS_CHECK_TABLES: "true" + INVIDIOUS_CHANNEL_THREADS: 1 + INVIDIOUS_FEED_THREADS: 1 depends_on: - postgres diff --git a/docker/Dockerfile b/docker/Dockerfile index f7d990d7..546ab0a1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -26,6 +26,26 @@ COPY ./config/sql/ ./config/sql/ COPY ./locales/ ./locales/ COPY --from=builder /invidious/invidious . +ENV POSTGRES_USER kemal +ENV POSTGRES_PASS kemal +ENV POSTGRES_HOST postgres +ENV POSTGRES_DB invidious +ENV POSTGRES_PORT 5432 + +ENV INVIDIOUS_DOMAIN localhost +ENV INVIDIOUS_REGISTRATION_ENABLED true +ENV INVIDIOUS_DISABLE_PROXY false +ENV INVIDIOUS_HTTPS_ONLY false +ENV INVIDIOUS_FULL_REFRESH false +ENV INVIDIOUS_CHECK_TABLES true +ENV INVIDIOUS_CHANNEL_THREADS 1 +ENV INVIDIOUS_FEED_THREADS 1 + +COPY docker/startup /startup +RUN chown invidious:invidious /startup +RUN chmod 700 /startup +RUN chown -R invidious:invidious /invidious/config/sql + EXPOSE 3000 USER invidious -CMD [ "/invidious/invidious" ] +CMD [ "/startup" ] diff --git a/docker/init-invidious-db.sh b/docker/init-invidious-db.sh index 3808e673..57d45ddd 100755 --- a/docker/init-invidious-db.sh +++ b/docker/init-invidious-db.sh @@ -1,10 +1,6 @@ #!/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 diff --git a/docker/startup b/docker/startup new file mode 100644 index 00000000..c25872ce --- /dev/null +++ b/docker/startup @@ -0,0 +1,26 @@ +#!/bin/sh + +echo "Configuring Invidious" + +cat < /invidious/config/config.yml +channel_threads: $INVIDIOUS_CHANNEL_THREADS +check_tables: $INVIDIOUS_CHECK_TABLES +feed_threads: $INVIDIOUS_FEED_THREADS +db: + user: $POSTGRES_USER + password: $POSTGRES_PASS + host: $POSTGRES_HOST + port: $POSTGRES_PORT + dbname: $POSTGRES_DB +full_refresh: $INVIDIOUS_FULL_REFRESH +https_only: $INVIDIOUS_HTTPS_ONLY +domain: $INVIDIOUS_DOMAIN +registration_enabled: $INVIDIOUS_REGISTRATION_ENABLED +disable_proxy: $INVIDIOUS_DISABLE_PROXY +EOF + +# kemal is the hardcoded postgres username +for i in /invidious/config/sql/*.sql; do sed -i s/kemal/$POSTGRES_USER/g $i; done + +echo "Starting Invidious" +exec /invidious/invidious \ No newline at end of file