|
|
FROM python:3.11.6-slim |
|
|
|
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 \ |
|
|
PYTHONPATH="/app" \ |
|
|
DEBIAN_FRONTEND=noninteractive \ |
|
|
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \ |
|
|
STREAMLIT_SERVER_PORT=7860 |
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
|
build-essential \ |
|
|
libglib2.0-0 \ |
|
|
libsm6 \ |
|
|
libxrender1 \ |
|
|
libxext6 \ |
|
|
git \ |
|
|
curl \ |
|
|
wget \ |
|
|
procps \ |
|
|
net-tools \ |
|
|
&& apt-get clean \ |
|
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
|
|
|
RUN groupadd -r appuser && useradd -r -g appuser appuser |
|
|
|
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
COPY requirements.txt /app/ |
|
|
RUN pip install --no-cache-dir --upgrade pip && \ |
|
|
pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
|
|
|
COPY path_config.py /app/ |
|
|
|
|
|
|
|
|
COPY docker_validation.py /app/ |
|
|
|
|
|
|
|
|
COPY . /app |
|
|
|
|
|
|
|
|
|
|
|
RUN mkdir -p /app/data /app/model /app/logs /app/cache /app/temp && \ |
|
|
chmod -R 755 /app/data /app/model /app/logs /app/cache /app/temp |
|
|
|
|
|
|
|
|
RUN chmod 777 /app/logs || echo "Could not set logs permissions, will use fallback logging" |
|
|
|
|
|
|
|
|
RUN chmod +x /app/start.sh |
|
|
|
|
|
|
|
|
COPY health_check.sh /app/ |
|
|
RUN chmod +x /app/health_check.sh |
|
|
|
|
|
|
|
|
|
|
|
RUN if [ -d /app/data/kaggle ]; then \ |
|
|
echo "Kaggle datasets found in app structure"; \ |
|
|
fi && \ |
|
|
if [ -f /app/data/combined_dataset.csv ]; then \ |
|
|
echo "Combined dataset found in app structure"; \ |
|
|
fi |
|
|
|
|
|
|
|
|
RUN python /app/initialize_system.py |
|
|
|
|
|
|
|
|
RUN python3 -c "\ |
|
|
import sys; \ |
|
|
sys.path.append('/app'); \ |
|
|
from path_config import path_manager; \ |
|
|
print(f'Container environment: {path_manager.environment}'); \ |
|
|
print(f'Base directory: {path_manager.base_paths[\"base\"]}'); \ |
|
|
print(f'Data directory: {path_manager.base_paths[\"data\"]}'); \ |
|
|
print(f'Model directory: {path_manager.base_paths[\"model\"]}'); \ |
|
|
critical_files = [path_manager.get_combined_dataset_path(), path_manager.get_model_file_path(), path_manager.get_vectorizer_path()]; \ |
|
|
[print(f'β
{file_path}' if file_path.exists() else f'β {file_path}') for file_path in critical_files]; \ |
|
|
print('System check completed')" |
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ |
|
|
CMD /app/health_check.sh |
|
|
|
|
|
|
|
|
RUN chown -R appuser:appuser /app |
|
|
|
|
|
|
|
|
USER appuser |
|
|
|
|
|
|
|
|
EXPOSE 7860 8000 |
|
|
|
|
|
|
|
|
ENV DOCKER_CONTAINER=1 |
|
|
|
|
|
|
|
|
CMD ["./start.sh"] |