mirror of
https://github.com/pacnpal/simpleguardhome.git
synced 2025-12-19 20:11:14 -05:00
feat(docker): streamline Dockerfile by optimizing layer caching and enhancing installation verification
This commit is contained in:
50
Dockerfile
50
Dockerfile
@@ -20,46 +20,38 @@ RUN apt-get update && \
|
|||||||
# Add architecture-specific compiler flags if needed
|
# Add architecture-specific compiler flags if needed
|
||||||
ENV ARCHFLAGS=""
|
ENV ARCHFLAGS=""
|
||||||
|
|
||||||
# Create necessary directories and set permissions
|
# Copy requirements first to leverage Docker cache
|
||||||
RUN mkdir -p /app/src/simpleguardhome && \
|
COPY requirements.txt /app/
|
||||||
chmod -R 755 /app
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Copy source code, maintaining directory structure
|
# Copy the entire project
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
||||||
# Debug: Show the copied files and set execute permission for entrypoint script
|
# Debug: Show project structure after copy
|
||||||
RUN echo "Project structure:" && \
|
RUN echo "Project structure after copy:" && \
|
||||||
tree /app && \
|
tree /app && \
|
||||||
echo "Package directory contents:" && \
|
echo "Verifying source directory:" && \
|
||||||
ls -la /app/src/simpleguardhome/ && \
|
if [ ! -d "/app/src/simpleguardhome" ]; then \
|
||||||
|
echo "ERROR: Source directory missing!" && \
|
||||||
|
exit 1; \
|
||||||
|
fi && \
|
||||||
|
echo "Source directory contents:" && \
|
||||||
|
ls -la /app/src/simpleguardhome/
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chmod -R 755 /app && \
|
||||||
chmod +x /app/docker-entrypoint.sh && \
|
chmod +x /app/docker-entrypoint.sh && \
|
||||||
cp /app/docker-entrypoint.sh /usr/local/bin/
|
cp /app/docker-entrypoint.sh /usr/local/bin/
|
||||||
|
|
||||||
# Set PYTHONPATH
|
# Set PYTHONPATH
|
||||||
ENV PYTHONPATH=/app/src
|
ENV PYTHONPATH=/app/src
|
||||||
|
|
||||||
# Install Python requirements and verify the package
|
# Install Python package in development mode
|
||||||
RUN pip install --no-cache-dir -r requirements.txt && \
|
RUN set -e && \
|
||||||
set -e && \
|
|
||||||
echo "Installing package..." && \
|
echo "Installing package..." && \
|
||||||
pip uninstall -y simpleguardhome || true && \
|
pip install -e . && \
|
||||||
# Debug: Show package files
|
echo "Verifying package installation..." && \
|
||||||
echo "Python path:" && \
|
python3 -c "import simpleguardhome; print('Package location:', simpleguardhome.__file__)" && \
|
||||||
python3 -c "import sys; print('\n'.join(sys.path))" && \
|
|
||||||
echo "Source directory contents:" && \
|
|
||||||
ls -R /app/src && \
|
|
||||||
# Install package in editable mode with compatibility mode enabled
|
|
||||||
pip install --use-pep517 -e . --config-settings editable_mode=compat && \
|
|
||||||
echo "Verifying installation..." && \
|
|
||||||
pip show simpleguardhome && \
|
|
||||||
# List all package files
|
|
||||||
echo "Package contents:" && \
|
|
||||||
find /app/src/simpleguardhome -type f -ls && \
|
|
||||||
# Verify package can be imported
|
|
||||||
echo "Testing import..." && \
|
|
||||||
python3 -c "import simpleguardhome; print(f'Package found at: {simpleguardhome.__file__}')" && \
|
|
||||||
# Verify app can be imported
|
|
||||||
echo "Testing app import..." && \
|
|
||||||
python3 -c "from simpleguardhome.main import app; print('App imported successfully')" && \
|
python3 -c "from simpleguardhome.main import app; print('App imported successfully')" && \
|
||||||
echo "Package installation successful" && \
|
echo "Package installation successful" && \
|
||||||
# Create rules backup directory with proper permissions
|
# Create rules backup directory with proper permissions
|
||||||
|
|||||||
@@ -22,21 +22,11 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
# Using explicit package configuration
|
|
||||||
package-dir = {"" = "src"}
|
package-dir = {"" = "src"}
|
||||||
packages = ["simpleguardhome"]
|
packages = ["simpleguardhome"]
|
||||||
|
|
||||||
# Include all package data
|
|
||||||
[tool.setuptools.package-data]
|
[tool.setuptools.package-data]
|
||||||
"*" = ["*.ico", "templates/*.html"]
|
|
||||||
|
|
||||||
# Explicitly include the package data
|
|
||||||
[options.package_data]
|
|
||||||
simpleguardhome = [
|
simpleguardhome = [
|
||||||
"templates/*",
|
"templates/*.html",
|
||||||
"favicon.ico"
|
"favicon.ico"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Make sure data files are included
|
|
||||||
[options]
|
|
||||||
include_package_data = true
|
|
||||||
22
setup.py
22
setup.py
@@ -1,3 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup()
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
setup(
|
||||||
|
package_dir={"": "src"},
|
||||||
|
packages=["simpleguardhome"],
|
||||||
|
package_data={
|
||||||
|
"simpleguardhome": [
|
||||||
|
"templates/*",
|
||||||
|
"favicon.ico"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
include_package_data=True
|
||||||
|
)
|
||||||
|
except: # noqa
|
||||||
|
print(
|
||||||
|
"\n\nAn error occurred while building the project, "
|
||||||
|
"please ensure you have the most updated version of setuptools, "
|
||||||
|
"setuptools_scm and wheel with:\n"
|
||||||
|
" pip install -U setuptools setuptools_scm wheel\n\n"
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user