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 restart: unless-stopped
volumes: volumes:
- postgresdata:/var/lib/postgresql/data - postgresdata:/var/lib/postgresql/data
- ./config/sql:/config/sql
- ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh
environment: environment:
POSTGRES_DB: invidious POSTGRES_DB: invidiousdb
POSTGRES_PASSWORD: kemal POSTGRES_PASSWORD: R3p1aceW1thStr0ngPa33word
POSTGRES_USER: kemal POSTGRES_USER: invidious
healthcheck: healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"] test: ["CMD", "pg_isready", "-U", "postgres"]
invidious: invidious:
@ -21,20 +19,19 @@ services:
ports: ports:
- "127.0.0.1:3000:3000" - "127.0.0.1:3000:3000"
environment: environment:
# Adapted from ./config/config.yml POSTGRES_USER: invidious
INVIDIOUS_CONFIG: | POSTGRES_PASS: R3p1aceW1thStr0ngPa33word
channel_threads: 1 POSTGRES_HOST: postgres
check_tables: true POSTGRES_DB: invidiousdb
feed_threads: 1 POSTGRES_PORT: 5432
db: INVIDIOUS_DOMAIN: localhost
user: kemal INVIDIOUS_REGISTRATION_ENABLED: "true"
password: kemal INVIDIOUS_DISABLE_PROXY: "false"
host: postgres INVIDIOUS_HTTPS_ONLY: "false"
port: 5432 INVIDIOUS_FULL_REFRESH: "false"
dbname: invidious INVIDIOUS_CHECK_TABLES: "true"
full_refresh: false INVIDIOUS_CHANNEL_THREADS: 1
https_only: false INVIDIOUS_FEED_THREADS: 1
domain:
depends_on: depends_on:
- postgres - postgres

View File

@ -26,6 +26,26 @@ COPY ./config/sql/ ./config/sql/
COPY ./locales/ ./locales/ COPY ./locales/ ./locales/
COPY --from=builder /invidious/invidious . 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 EXPOSE 3000
USER invidious USER invidious
CMD [ "/invidious/invidious" ] CMD [ "/startup" ]

View File

@ -1,10 +1,6 @@
#!/bin/bash #!/bin/bash
set -eou pipefail 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/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/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/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