From 26c2adf1d5d65bddfeeb1e929978535e8230c673 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:59:09 -0500 Subject: [PATCH] refactor(docker): update Dockerfile and entrypoint script for improved package management and application startup --- Dockerfile | 11 +++++++---- docker-entrypoint.sh | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91eaadf..b5eb554 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,11 +13,14 @@ RUN apt-get update && \ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# Copy the package directly to /app for simpler imports -COPY src/simpleguardhome /app/simpleguardhome +# Copy the source code +COPY . . -# Create rules_backup directory with proper permissions -RUN mkdir -p rules_backup && chmod 777 rules_backup +# Clean any previous installations and install the package +RUN pip uninstall -y simpleguardhome || true && \ + pip install -e . && \ + pip show simpleguardhome && \ + python3 -c "import simpleguardhome; print('Package found at:', simpleguardhome.__file__)" # Set up health check COPY healthcheck.py /usr/local/bin/ diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index cf42997..92cd17e 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,5 +3,10 @@ set -e echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting SimpleGuardHome..." -# Just run uvicorn pointing to the app -exec python3 -m uvicorn simpleguardhome.main:app --host 0.0.0.0 --port 8000 \ No newline at end of file +# Verify package can be imported +echo "Verifying package installation..." +python3 -c "import simpleguardhome" || exit 1 + +# Start the application +echo "Starting SimpleGuardHome server..." +exec python3 -m simpleguardhome.main \ No newline at end of file