From: Adam Dullage Date: Sun, 10 Sep 2023 14:46:01 +0000 (+0100) Subject: entrypoint DRY refactor and removal of user/group creation X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=27840f11242476b75ab679da21ce33302c6d7182;p=flatnotes.git entrypoint DRY refactor and removal of user/group creation --- diff --git a/entrypoint.sh b/entrypoint.sh index 4fd2822..b317c95 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,51 +1,30 @@ #!/bin/bash +set -e + echo "WARNING: Breaking changes introduced in version 3.x:" echo " - The port flatnotes uses inside the Docker container has been changed to 8080 (previously 80)." echo " - To accompany the above change, support for the PORT environment variable has been removed." echo " - The note directory inside the Docker container has moved from /app/data to simply /data." +flatnotes_command="python -m \ + uvicorn \ + main:app \ + --app-dir flatnotes \ + --host 0.0.0.0 \ + --port 8080 \ + --proxy-headers \ + --forwarded-allow-ips '*'" + if [ `id -u` -eq 0 ] && [ `id -g` -eq 0 ]; then - set -e - - USERNAME=flatnotes - - echo Setting up user and group... - addgroup \ - --gid ${PGID} \ - ${USERNAME} \ - || echo "Group '${PGID}' already exists." - - adduser \ - --disabled-password \ - --gecos "" \ - --uid ${PUID} \ - --gid ${PGID} \ - ${USERNAME} \ - || echo "User '${PUID}' already exists." - echo Setting file permissions... chown -R ${PUID}:${PGID} ${FLATNOTES_PATH} - echo Starting flatnotes... - cd ${APP_PATH} - exec gosu ${PUID}:${PGID} \ - python -m \ - uvicorn \ - main:app \ - --app-dir flatnotes \ - --host 0.0.0.0 \ - --port 8080 \ - --proxy-headers \ - --forwarded-allow-ips "*" + echo Starting flatnotes as user ${PUID}... + exec gosu ${PUID}:${PGID} ${flatnotes_command} + else - echo "A user was set by docker, skipping permissions setup." - exec python -m \ - uvicorn \ - main:app \ - --app-dir flatnotes \ - --host 0.0.0.0 \ - --port 8080 \ - --proxy-headers \ - --forwarded-allow-ips "*" + echo "A user was set by docker, skipping file permission changes." + echo Starting flatnotes as user $(id -u)... + exec ${flatnotes_command} fi