diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5fa4511..bea3ffe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,12 +15,6 @@ jobs: - name: Check out the repo uses: actions/checkout@v7 - - name: Log in to Docker Hub - uses: docker/login-action@v4 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Log in to the Container registry uses: docker/login-action@v4 with: @@ -42,7 +36,6 @@ jobs: uses: docker/metadata-action@v6 with: images: | - wallabag/wallabag ghcr.io/${{ github.repository }} - name: Build and push Docker images diff --git a/README.md b/README.md index 1d422ba..c00c44d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Default login is `wallabag:wallabag`. - `-e MYSQL_ROOT_PASSWORD=...` (needed for the mariadb container to initialise and for the entrypoint in the wallabag container to create a database and user if its not there) - `-e POSTGRES_PASSWORD=...` (needed for the postgres container to initialise and for the entrypoint in the wallabag container to create a database and user if not there) - `-e POSTGRES_USER=...` (needed for the posgres container to initialise and for the entrypoint in the wallabag container to create a database and user if not there) +- `-e POSTGRES_DATABASE_NAME=...` (optional: psql always connects to the database that matches the user name. this allows using a different name from user) - `-e SYMFONY__ENV__DATABASE_DRIVER=...` (defaults to "pdo_sqlite", this sets the database driver to use) - `-e SYMFONY__ENV__DATABASE_HOST=...` (defaults to "127.0.0.1", if use mysql this should be the name of the mariadb container) - `-e SYMFONY__ENV__DATABASE_PORT=...` (port of the database host) diff --git a/root/entrypoint.sh b/root/entrypoint.sh index bf44ec8..80c6691 100755 --- a/root/entrypoint.sh +++ b/root/entrypoint.sh @@ -73,9 +73,16 @@ provisioner() { # Configure Postgres database if [ "$SYMFONY__ENV__DATABASE_DRIVER" = "pdo_pgsql" ] && [ "$POPULATE_DATABASE" = "True" ] && [ "$POSTGRES_PASSWORD" != "" ] ; then + if [ -z "$POSTGRES_DATABASE_NAME" ]; then + echo "WARN: POSTGRES_DATABASE_NAME is not set. POSTGRES_USER will be used as database name" + else + export PGDATABASE="${POSTGRES_DATABASE_NAME}" + fi export PGPASSWORD="${POSTGRES_PASSWORD}" DATABASE_EXISTS="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \ -c "SELECT 1 FROM pg_catalog.pg_database WHERE datname = '${SYMFONY__ENV__DATABASE_NAME}';")" + TABLE_EXISTS="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \ + -c "SELECT 1 FROM information_schema.tables WHERE table_name = 'wallabag_user';")" if [ "$DATABASE_EXISTS" != "1" ]; then echo "Configuring the Postgres database ..." psql -q -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \ @@ -87,6 +94,9 @@ provisioner() { -c "CREATE ROLE ${SYMFONY__ENV__DATABASE_USER} with PASSWORD '${SYMFONY__ENV__DATABASE_PASSWORD}' LOGIN;" fi install_wallabag + elif [ "$TABLE_EXISTS" != "1" ]; then + echo "Wallabag user and database is set already but tables not initialized, running install_wallabag ..." + install_wallabag else echo "WARN: Postgres database is already configured. Remove the environment variable with root password." fi