docker-entrypoint.sh 778 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. set -e
  3. # Fix data directory permissions when running as root.
  4. # Docker named volumes / host bind-mounts may be owned by root,
  5. # preventing the non-root sub2api user from writing files.
  6. if [ "$(id -u)" = "0" ]; then
  7. mkdir -p /app/data
  8. # Use || true to avoid failure on read-only mounted files (e.g. config.yaml:ro)
  9. chown -R sub2api:sub2api /app/data 2>/dev/null || true
  10. # Re-invoke this script as sub2api so the flag-detection below
  11. # also runs under the correct user.
  12. exec su-exec sub2api "$0" "$@"
  13. fi
  14. # Compatibility: if the first arg looks like a flag (e.g. --help),
  15. # prepend the default binary so it behaves the same as the old
  16. # ENTRYPOINT ["/app/sub2api"] style.
  17. if [ "${1#-}" != "$1" ]; then
  18. set -- /app/sub2api "$@"
  19. fi
  20. exec "$@"