docker-entrypoint.sh 748 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. set -x
  3. # Get the PUID and PGID from environment variables (or use default values 1000 if not set)
  4. PUID=${PUID:-1000}
  5. PGID=${PGID:-1000}
  6. # Check if the provided PUID and PGID are non-empty, numeric values; otherwise, assign default values
  7. if ! [[ "$PUID" =~ ^[0-9]+$ ]]; then
  8. PUID=1000
  9. fi
  10. if ! [[ "$PGID" =~ ^[0-9]+$ ]]; then
  11. PGID=1000
  12. fi
  13. # Check if the specified group with PGID exists, if not, create it
  14. if ! getent group "$PGID" >/dev/null; then
  15. groupadd -g "$PGID" appgroup
  16. fi
  17. useradd --create-home --shell /bin/bash --uid "$PUID" --gid "$PGID" appuser
  18. chown -R appuser:appgroup /app
  19. chmod -R 777 /usr/share/fonts
  20. chmod -R 777 /var/cache/fontconfig
  21. chmod -R 777 /usr/local/share/fonts
  22. exec su appuser -p -c "cd /app && $@"