mirror of
https://github.com/pacnpal/simpleguardhome.git
synced 2025-12-20 04:21:13 -05:00
feat(docker): enhance Dockerfile and entrypoint for improved package verification and diagnostics
This commit is contained in:
24
Dockerfile
24
Dockerfile
@@ -18,22 +18,26 @@ 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 requirements first for better caching
|
# Copy source code first
|
||||||
COPY requirements.txt .
|
COPY . /app/
|
||||||
|
|
||||||
# Install Python dependencies in venv
|
# Set PYTHONPATH
|
||||||
|
ENV PYTHONPATH=/app/src
|
||||||
|
|
||||||
|
# Install requirements
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Copy the source code
|
# Install the package in development mode
|
||||||
COPY . .
|
RUN cd /app && \
|
||||||
|
pip uninstall -y simpleguardhome || true && \
|
||||||
# Clean any previous installations and install the package
|
|
||||||
RUN pip uninstall -y simpleguardhome || true && \
|
|
||||||
pip install -e . && \
|
pip install -e . && \
|
||||||
|
echo "Verifying installation..." && \
|
||||||
pip show simpleguardhome && \
|
pip show simpleguardhome && \
|
||||||
pip list && \
|
pip list | grep simpleguardhome && \
|
||||||
python3 -c "import sys; print('Python path:', sys.path)" && \
|
python3 -c "import sys; print('Python path:', sys.path)" && \
|
||||||
python3 -c "import simpleguardhome; print('Package found at:', simpleguardhome.__file__)"
|
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/
|
||||||
|
|||||||
@@ -14,16 +14,22 @@ trap handle_term SIGTERM SIGINT
|
|||||||
|
|
||||||
# Print diagnostic information
|
# Print diagnostic information
|
||||||
echo "Verifying package installation..."
|
echo "Verifying package installation..."
|
||||||
echo "Python path:"
|
echo "PYTHONPATH environment variable:"
|
||||||
|
echo $PYTHONPATH
|
||||||
|
echo "Directory contents of /app/src:"
|
||||||
|
ls -la /app/src/
|
||||||
|
echo "Directory contents of /app/src/simpleguardhome:"
|
||||||
|
ls -la /app/src/simpleguardhome/
|
||||||
|
echo "Python sys.path:"
|
||||||
python3 -c "import sys; print('\n'.join(sys.path))"
|
python3 -c "import sys; print('\n'.join(sys.path))"
|
||||||
echo "Installed packages:"
|
echo "Installed packages:"
|
||||||
pip list
|
pip list | grep simpleguardhome
|
||||||
echo "Attempting to import simpleguardhome..."
|
echo "Attempting to import and locate simpleguardhome..."
|
||||||
python3 -c "import simpleguardhome; print('Successfully imported simpleguardhome')" || exit 1
|
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
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
echo "Starting SimpleGuardHome server..."
|
echo "Starting SimpleGuardHome server..."
|
||||||
exec python3 -m simpleguardhome.main
|
exec python3 -c "from simpleguardhome import start; start()"
|
||||||
|
|
||||||
# Store child PID
|
# Store child PID
|
||||||
child=$!
|
child=$!
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name="simpleguardhome",
|
name="simpleguardhome",
|
||||||
version="0.1.0",
|
version="0.1.0",
|
||||||
packages=find_packages(where="src"),
|
packages=find_packages(where="src", include=["simpleguardhome*"]),
|
||||||
package_dir={"": "src"},
|
package_dir={"": "src"},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
package_data={
|
package_data={
|
||||||
|
|||||||
@@ -188,10 +188,10 @@ def start():
|
|||||||
"""Start the application using uvicorn."""
|
"""Start the application using uvicorn."""
|
||||||
import uvicorn
|
import uvicorn
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
"simpleguardhome.main:app",
|
app,
|
||||||
host="0.0.0.0",
|
host="0.0.0.0",
|
||||||
port=8000,
|
port=8000,
|
||||||
reload=True
|
reload=False # Disable reload in Docker
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user