Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
25 changes: 22 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,31 @@ RUN addgroup -g 1000 -S invidious && \
adduser -u 1000 -S invidious -G invidious
COPY ./assets/ ./assets/
COPY --chown=invidious ./config/config.* ./config/
RUN mv -n config/config.example.yml config/config.yml
RUN sed -i 's/host: \(127.0.0.1\|localhost\)/host: postgres/' config/config.yml

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" ]
4 changes: 0 additions & 4 deletions docker/init-invidious-db.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 32 additions & 0 deletions docker/startup
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

CONF_FILE="/invidious/config/config.yml"

if [ -f "$CONF_FILE" ]; then
echo "Existing configuration found. Skipping environment variable based conifg..."
else
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
fi

# 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