mirror of
https://github.com/pacnpal/simpleguardhome.git
synced 2025-12-20 12:31:16 -05:00
feat(docker): improve Dockerfile with enhanced package installation verification and diagnostics
This commit is contained in:
40
Dockerfile
40
Dockerfile
@@ -1,10 +1,9 @@
|
|||||||
# Use official Python base image
|
# Use official Python base image
|
||||||
FROM python:3.11-slim-bullseye
|
FROM python:3.11-slim-bullseye
|
||||||
|
|
||||||
# Set and create working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN mkdir -p /app/src/simpleguardhome && \
|
|
||||||
chmod -R 755 /app
|
|
||||||
# Install system dependencies with architecture-specific handling
|
# Install system dependencies with architecture-specific handling
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
@@ -19,39 +18,38 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
# Add architecture-specific compiler flags if needed
|
# Add architecture-specific compiler flags if needed
|
||||||
ENV ARCHFLAGS=""
|
ENV ARCHFLAGS=""
|
||||||
&& python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
|
||||||
|
|
||||||
# Ensure pip is up to date
|
# Create necessary directories and set permissions
|
||||||
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
RUN mkdir -p /app/src/simpleguardhome && \
|
||||||
|
chmod -R 755 /app
|
||||||
|
|
||||||
# Create necessary directories
|
# Copy source code, maintaining directory structure
|
||||||
RUN mkdir -p /app/src
|
|
||||||
|
|
||||||
# Copy source code first, maintaining directory structure
|
|
||||||
COPY setup.py requirements.txt /app/
|
COPY setup.py requirements.txt /app/
|
||||||
COPY src /app/src/
|
COPY src /app/src/
|
||||||
|
|
||||||
# Set PYTHONPATH
|
# Set PYTHONPATH
|
||||||
ENV PYTHONPATH=/app/src
|
ENV PYTHONPATH=/app/src
|
||||||
|
|
||||||
# Verify directory structure
|
# Install Python requirements
|
||||||
RUN ls -R /app
|
|
||||||
|
|
||||||
# Set up working directory and 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 with additional error handling
|
# Install and verify the package
|
||||||
RUN echo "Installing package..." && \
|
RUN set -e && \
|
||||||
|
echo "Installing package..." && \
|
||||||
pip uninstall -y simpleguardhome || true && \
|
pip uninstall -y simpleguardhome || true && \
|
||||||
|
# First install dependencies only
|
||||||
pip install --no-deps -v -e . && \
|
pip install --no-deps -v -e . && \
|
||||||
|
# Then install package with dependencies
|
||||||
pip install -e . && \
|
pip install -e . && \
|
||||||
echo "Installation complete, verifying..." && \
|
echo "Verifying installation..." && \
|
||||||
pip show simpleguardhome && \
|
pip show simpleguardhome && \
|
||||||
echo "Package files:" && \
|
# List all package files
|
||||||
find /app/src/simpleguardhome -type f && \
|
echo "Package contents:" && \
|
||||||
|
find /app/src/simpleguardhome -type f -ls && \
|
||||||
|
# Verify import works
|
||||||
echo "Testing import..." && \
|
echo "Testing import..." && \
|
||||||
PYTHONPATH=/app/src python3 -c "import simpleguardhome; from simpleguardhome.main import app; print('Package successfully imported')"
|
python3 -c "import simpleguardhome; from simpleguardhome.main import app; print(f'Package found at: {simpleguardhome.__file__}')" && \
|
||||||
|
echo "Package installation successful"
|
||||||
|
|
||||||
# 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/
|
||||||
|
|||||||
Reference in New Issue
Block a user