diff --git a/Dockerfile b/Dockerfile index 94d1612c6..6411e528e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,4 +74,13 @@ RUN echo "GIT_COMMIT=${GIT_COMMIT}" > build.txt \ # Run command EXPOSE 8000 + +# Add healthcheck to verify the API is responsive using the internal Python interpreter +HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ + CMD python3 -c "import os, urllib.request; \ + port = os.getenv('SPOOLMAN_PORT', '8000'); \ + base = os.getenv('SPOOLMAN_BASE_PATH', '').strip('/'); \ + path = f'/{base}/api/v1/health'.replace('//', '/'); \ + urllib.request.urlopen(f'http://localhost:{port}{path}')" || exit 1 + ENTRYPOINT ["/home/app/spoolman/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..10b89afe8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' +services: + spoolman: + image: ghcr.io/donkie/spoolman:latest # Also available at dockerhub: donkieyo/spoolman:latest + restart: unless-stopped + volumes: + # Mount the host machine's ./data directory into the container's /home/app/.local/share/spoolman directory + - ./data:/home/app/.local/share/spoolman # Do NOT modify /home/app/.local/share/spoolman target + ports: + # Map the host machine's port 7912 to the container's port 8000 + - "7912:8000" + environment: + - TZ=Europe/Stockholm # Optional, defaults to UTC