diff options
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/Dockerfile | 23 | ||||
| -rw-r--r-- | docker/Dockerfile.postgres | 12 | ||||
| -rwxr-xr-x | docker/entrypoint.postgres.sh | 30 | ||||
| -rwxr-xr-x | docker/init-invidious-db.sh | 16 |
4 files changed, 25 insertions, 56 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index d0e4827a..96f844fe 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,25 +1,20 @@ -FROM alpine:edge AS builder -RUN apk add --no-cache curl crystal shards libc-dev \ - yaml-dev libxml2-dev sqlite-dev zlib-dev openssl-dev \ - yaml-static sqlite-static zlib-static openssl-libs-static +FROM crystallang/crystal:0.35.1-alpine AS builder +RUN apk add --no-cache curl sqlite-static WORKDIR /invidious -RUN curl -Lo /etc/apk/keys/omarroth.rsa.pub https://github.com/omarroth/boringssl-alpine/releases/download/1.1.0-r0/omarroth.rsa.pub && \ - curl -Lo boringssl-dev.apk https://github.com/omarroth/boringssl-alpine/releases/download/1.1.0-r0/boringssl-dev-1.1.0-r0.apk && \ - curl -Lo lsquic.apk https://github.com/omarroth/lsquic-alpine/releases/download/2.6.3-r0/lsquic-2.6.3-r0.apk && \ - apk verify --no-cache boringssl-dev.apk lsquic.apk && \ - tar -xf boringssl-dev.apk usr/lib/libcrypto.a usr/lib/libssl.a && \ - tar -xf lsquic.apk usr/lib/liblsquic.a && \ - rm /etc/apk/keys/omarroth.rsa.pub boringssl-dev.apk lsquic.apk COPY ./shard.yml ./shard.yml RUN shards update && shards install && \ - mv ./usr/lib/* ./lib/lsquic/src/lsquic/ext && \ - rm -r ./usr /root/.cache + # TODO: Document build instructions + # See https://github.com/omarroth/boringssl-alpine/blob/master/APKBUILD, + # https://github.com/omarroth/lsquic-alpine/blob/master/APKBUILD, + # https://github.com/omarroth/lsquic.cr/issues/1#issuecomment-631610081 + # for details building static lib + curl -Lo ./lib/lsquic/src/lsquic/ext/liblsquic.a https://omar.yt/lsquic/liblsquic-v2.18.1.a COPY ./src/ ./src/ # TODO: .git folder is required for building – this is destructive. # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION. COPY ./.git/ ./.git/ RUN crystal build ./src/invidious.cr \ - --static --warnings all --error-on-warnings \ + --static --warnings all \ --link-flags "-lxml2 -llzma" FROM alpine:latest diff --git a/docker/Dockerfile.postgres b/docker/Dockerfile.postgres deleted file mode 100644 index 3b25b802..00000000 --- a/docker/Dockerfile.postgres +++ /dev/null @@ -1,12 +0,0 @@ -FROM postgres:10 - -ENV POSTGRES_USER postgres -# Do not require a PostgreSQL superuser password. -# See https://github.com/docker-library/postgres/issues/681. -ENV POSTGRES_HOST_AUTH_METHOD trust - -ADD ./config/sql /config/sql -ADD ./docker/entrypoint.postgres.sh /entrypoint.sh - -ENTRYPOINT [ "/entrypoint.sh" ] -CMD [ "postgres" ] diff --git a/docker/entrypoint.postgres.sh b/docker/entrypoint.postgres.sh deleted file mode 100755 index be6f6782..00000000 --- a/docker/entrypoint.postgres.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -CMD="$@" -if [ ! -f /var/lib/postgresql/data/setupFinished ]; then - echo "### first run - setting up invidious database" - /usr/local/bin/docker-entrypoint.sh postgres & - sleep 10 - until runuser -l postgres -c 'pg_isready' 2>/dev/null; do - >&2 echo "### Postgres is unavailable - waiting" - sleep 5 - done - >&2 echo "### importing table schemas" - su postgres -c 'createdb invidious' - su postgres -c 'psql -c "CREATE USER kemal WITH PASSWORD '"'kemal'"'"' - su postgres -c 'psql invidious kemal < config/sql/channels.sql' - su postgres -c 'psql invidious kemal < config/sql/videos.sql' - su postgres -c 'psql invidious kemal < config/sql/channel_videos.sql' - su postgres -c 'psql invidious kemal < config/sql/users.sql' - su postgres -c 'psql invidious kemal < config/sql/session_ids.sql' - su postgres -c 'psql invidious kemal < config/sql/nonces.sql' - su postgres -c 'psql invidious kemal < config/sql/annotations.sql' - su postgres -c 'psql invidious kemal < config/sql/playlists.sql' - su postgres -c 'psql invidious kemal < config/sql/playlist_videos.sql' - touch /var/lib/postgresql/data/setupFinished - echo "### invidious database setup finished" - exit -fi - -echo "running postgres /usr/local/bin/docker-entrypoint.sh $CMD" -exec /usr/local/bin/docker-entrypoint.sh $CMD diff --git a/docker/init-invidious-db.sh b/docker/init-invidious-db.sh new file mode 100755 index 00000000..6c8ad3a7 --- /dev/null +++ b/docker/init-invidious-db.sh @@ -0,0 +1,16 @@ +#!/bin/sh +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 |
