mirror of
https://github.com/pacnpal/simpleguardhome.git
synced 2025-12-20 04:21:13 -05:00
feat(docker): enhance Dockerfile and entrypoint with improved package verification and diagnostics
This commit is contained in:
31
Dockerfile
31
Dockerfile
@@ -1,8 +1,10 @@
|
|||||||
# Use official Python base image
|
# Use official Python base image
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
# Set working directory
|
# Set and create working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
RUN mkdir -p /app/src/simpleguardhome && \
|
||||||
|
chmod -R 755 /app
|
||||||
|
|
||||||
# Install system dependencies
|
# Install system dependencies
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
@@ -18,26 +20,33 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|||||||
# Upgrade pip and essential tools
|
# Upgrade pip and essential tools
|
||||||
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
||||||
|
|
||||||
# Copy source code first
|
# Create necessary directories
|
||||||
COPY . /app/
|
RUN mkdir -p /app/src
|
||||||
|
|
||||||
|
# Copy source code first, maintaining directory structure
|
||||||
|
COPY setup.py requirements.txt /app/
|
||||||
|
COPY src /app/src/
|
||||||
|
|
||||||
# Set PYTHONPATH
|
# Set PYTHONPATH
|
||||||
ENV PYTHONPATH=/app/src
|
ENV PYTHONPATH=/app/src
|
||||||
|
|
||||||
|
# Verify directory structure
|
||||||
|
RUN ls -R /app
|
||||||
|
|
||||||
# Install requirements
|
# Install requirements
|
||||||
|
WORKDIR /app
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Install the package in development mode
|
# Install the package in development mode with verbose output
|
||||||
RUN cd /app && \
|
RUN echo "Installing package..." && \
|
||||||
pip uninstall -y simpleguardhome || true && \
|
pip uninstall -y simpleguardhome || true && \
|
||||||
pip install -e . && \
|
pip install -e . && \
|
||||||
echo "Verifying installation..." && \
|
echo "Verifying package files..." && \
|
||||||
|
ls -R /app/src/simpleguardhome/ && \
|
||||||
|
echo "Checking package installation..." && \
|
||||||
pip show simpleguardhome && \
|
pip show simpleguardhome && \
|
||||||
pip list | grep simpleguardhome && \
|
echo "Verifying import..." && \
|
||||||
python3 -c "import sys; print('Python path:', sys.path)" && \
|
python3 -c "import simpleguardhome; from simpleguardhome.main import app; print('Package imported successfully')"
|
||||||
echo "Testing import..." && \
|
|
||||||
python3 -c "import simpleguardhome; print('Found package at:', simpleguardhome.__file__)" && \
|
|
||||||
ls -la /app/src/simpleguardhome/
|
|
||||||
|
|
||||||
# Copy and set up entrypoint script
|
# Copy and set up entrypoint script
|
||||||
COPY docker-entrypoint.sh /usr/local/bin/
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
|||||||
@@ -12,20 +12,38 @@ handle_term() {
|
|||||||
# Set up signal handlers
|
# Set up signal handlers
|
||||||
trap handle_term SIGTERM SIGINT
|
trap handle_term SIGTERM SIGINT
|
||||||
|
|
||||||
# Print diagnostic information
|
# Verify package files exist
|
||||||
echo "Verifying package installation..."
|
echo "Verifying package files..."
|
||||||
echo "PYTHONPATH environment variable:"
|
if [ ! -d "/app/src/simpleguardhome" ]; then
|
||||||
echo $PYTHONPATH
|
echo "ERROR: Package directory not found!"
|
||||||
echo "Directory contents of /app/src:"
|
exit 1
|
||||||
ls -la /app/src/
|
fi
|
||||||
echo "Directory contents of /app/src/simpleguardhome:"
|
|
||||||
ls -la /app/src/simpleguardhome/
|
if [ ! -f "/app/src/simpleguardhome/__init__.py" ]; then
|
||||||
echo "Python sys.path:"
|
echo "ERROR: Package __init__.py not found!"
|
||||||
python3 -c "import sys; print('\n'.join(sys.path))"
|
exit 1
|
||||||
echo "Installed packages:"
|
fi
|
||||||
pip list | grep simpleguardhome
|
|
||||||
echo "Attempting to import and locate simpleguardhome..."
|
if [ ! -f "/app/src/simpleguardhome/main.py" ]; then
|
||||||
python3 -c "import simpleguardhome, os; print('Found at:', os.path.abspath(simpleguardhome.__file__)); print('Parent dir contents:', os.listdir(os.path.dirname(simpleguardhome.__file__)))" || exit 1
|
echo "ERROR: Package main.py not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print environment information
|
||||||
|
echo "Environment:"
|
||||||
|
echo "PYTHONPATH=$PYTHONPATH"
|
||||||
|
echo "Current directory: $(pwd)"
|
||||||
|
echo "Package contents:"
|
||||||
|
ls -R /app/src/simpleguardhome/
|
||||||
|
|
||||||
|
# Verify package can be imported
|
||||||
|
echo "Verifying package import..."
|
||||||
|
if ! python3 -c "import simpleguardhome; from simpleguardhome.main import app; print('Package imported successfully')"; then
|
||||||
|
echo "ERROR: Failed to import package!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "All checks passed. Starting server..."
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
echo "Starting SimpleGuardHome server..."
|
echo "Starting SimpleGuardHome server..."
|
||||||
|
|||||||
6
setup.py
6
setup.py
@@ -1,14 +1,16 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="simpleguardhome",
|
name="simpleguardhome",
|
||||||
version="0.1.0",
|
version="0.1.0",
|
||||||
packages=find_packages(where="src", include=["simpleguardhome*"]),
|
packages=find_packages(where="src"),
|
||||||
package_dir={"": "src"},
|
package_dir={"": "src"},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
package_data={
|
package_data={
|
||||||
"simpleguardhome": ["templates/*"]
|
"simpleguardhome": ["templates/*", "favicon.ico"]
|
||||||
},
|
},
|
||||||
|
python_requires=">=3.7",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"fastapi",
|
"fastapi",
|
||||||
"uvicorn",
|
"uvicorn",
|
||||||
|
|||||||
Reference in New Issue
Block a user