Ver código fonte

changes to implement generic entrypoint

Natan 1 ano atrás
pai
commit
6ec3985b6b
2 arquivos alterados com 19 adições e 11 exclusões
  1. 17 10
      docker-entrypoint.sh
  2. 2 1
      release.dockerfile

+ 17 - 10
docker-entrypoint.sh

@@ -1,27 +1,34 @@
 #!/bin/bash
+
 set -x
 # Get the PUID and PGID from environment variables (or use default values 1000 if not set)
 PUID=${PUID:-1000}
 PGID=${PGID:-1000}
 
-# Check if the provided PUID and PGID are non-empty, numeric values; otherwise, assign default values
+# Check if the provided PUID and PGID are non-empty, numeric values; otherwise, assign default values.
 if ! [[ "$PUID" =~ ^[0-9]+$ ]]; then
   PUID=1000
 fi
-
 if ! [[ "$PGID" =~ ^[0-9]+$ ]]; then
   PGID=1000
 fi
-
-# Check if the specified group with PGID exists, if not, create it
+# Check if the specified group with PGID exists, if not, create it.
 if ! getent group "$PGID" >/dev/null; then
   groupadd -g "$PGID" appgroup
 fi
-
+# Create user.
 useradd --create-home --shell /bin/bash --uid "$PUID" --gid "$PGID" appuser
+# Make user the owner of the app directory.
 chown -R appuser:appgroup /app
-chmod -R 777 /usr/share/fonts
-chmod -R 777 /var/cache/fontconfig
-chmod -R 777 /usr/local/share/fonts
-
-exec su appuser -p -c "cd /app && python main.py"
+# Set permissions on font directories.
+if [ -d "/usr/share/fonts" ]; then
+  chmod -R 777 /usr/share/fonts
+fi
+if [ -d "/var/cache/fontconfig" ]; then
+  chmod -R 777 /var/cache/fontconfig
+fi
+if [ -d "/usr/local/share/fonts" ]; then
+  chmod -R 777 /usr/local/share/fonts
+fi
+# Execute the application per the arguments to the file.
+exec su appuser -p -c "$@"

+ 2 - 1
release.dockerfile

@@ -17,4 +17,5 @@ RUN chmod 777 /resources/docker-entrypoint.sh
 EXPOSE 8080
 ENV PYTHONUNBUFFERED True
 
-ENTRYPOINT ["/resources/docker-entrypoint.sh"]
+ENTRYPOINT ["/resources/docker-entrypoint.sh"]
+CMD ["cd /app && python main.py"]