Configuration fixes for Docker and docker-compose

This commit is contained in:
Sumit Khanna 2021-04-27 22:41:11 -04:00
parent bfd02ac13d
commit 3ad17d54f3
4 changed files with 63 additions and 24 deletions

View File

@ -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

View File

@ -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" ]

View File

@ -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

26
docker/startup Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
echo "Configuring Invidious"
cat <<EOF > /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