From ceee425fab83194f2afcc1404d77ad4785fa5b48 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:42:37 -0500 Subject: [PATCH] refactor(docker): restructure Dockerfile to copy source code directory and create rules_backup volume --- Dockerfile | 10 ++++++++-- docker-entrypoint.sh | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ac89c2..eeb59f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,10 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy source code -COPY src/simpleguardhome /app/simpleguardhome/ +COPY src /app/src + +# Create rules_backup directory with proper permissions +RUN mkdir -p rules_backup && chmod 777 rules_backup # Set up health check COPY healthcheck.py /usr/local/bin/ @@ -34,4 +37,7 @@ EXPOSE 8000 COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh -ENTRYPOINT ["docker-entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["docker-entrypoint.sh"] + +# Mark rules_backup as a volume +VOLUME ["/app/rules_backup"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ec61f48..10c113f 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,5 +3,5 @@ set -e echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting SimpleGuardHome..." -# Start the application -exec python3 -m uvicorn simpleguardhome.main:app --host 0.0.0.0 --port 8000 \ No newline at end of file +# Run the app with src in Python path to find the module +PYTHONPATH=/app/src exec python3 -m uvicorn simpleguardhome.main:app --host 0.0.0.0 --port 8000 \ No newline at end of file