levalencia commited on
Commit
442515d
·
1 Parent(s): 6b37abd

Update Dockerfile to include test_permissions.py and enhance startup script for environment verification

Browse files

- Added test_permissions.py to the Dockerfile to verify environment setup.
- Modified the startup script to run the environment test before launching the Streamlit app, improving error handling and logging for environment validation.

Files changed (1) hide show
  1. Dockerfile +5 -5
Dockerfile CHANGED
@@ -77,6 +77,7 @@ RUN mkdir -p /app/.streamlit /tmp/docling_temp /tmp/easyocr_models /tmp/cache /t
77
  COPY requirements.txt ./
78
  COPY pyproject.toml ./
79
  COPY src/ ./src/
 
80
  COPY README.md ./
81
 
82
  # Create Streamlit config directly in Dockerfile to avoid copy issues
@@ -142,14 +143,13 @@ RUN echo '#!/bin/bash' > /app/start.sh && \
142
  echo 'echo "HF_HUB_CACHE: $HF_HUB_CACHE"' >> /app/start.sh && \
143
  echo 'echo "HF_CACHE_HOME: $HF_CACHE_HOME"' >> /app/start.sh && \
144
  echo 'echo "TEMP_DIR: $TEMP_DIR"' >> /app/start.sh && \
145
- echo 'echo "Testing cache directory access..."' >> /app/start.sh && \
146
- echo 'mkdir -p $HF_HUB_CACHE $HF_CACHE_HOME $TRANSFORMERS_CACHE $HF_DATASETS_CACHE $TORCH_HOME $TENSORFLOW_HOME $KERAS_HOME' >> /app/start.sh && \
147
  echo 'if [ $? -eq 0 ]; then' >> /app/start.sh && \
148
- echo ' echo "Cache directories created successfully"' >> /app/start.sh && \
149
- echo ' echo "Starting Streamlit app..."' >> /app/start.sh && \
150
  echo ' exec streamlit run src/streamlit_app.py --server.port=8501 --server.address=0.0.0.0' >> /app/start.sh && \
151
  echo 'else' >> /app/start.sh && \
152
- echo ' echo "Failed to create cache directories, exiting..."' >> /app/start.sh && \
153
  echo ' exit 1' >> /app/start.sh && \
154
  echo 'fi' >> /app/start.sh && \
155
  chmod +x /app/start.sh
 
77
  COPY requirements.txt ./
78
  COPY pyproject.toml ./
79
  COPY src/ ./src/
80
+ COPY test_permissions.py ./
81
  COPY README.md ./
82
 
83
  # Create Streamlit config directly in Dockerfile to avoid copy issues
 
143
  echo 'echo "HF_HUB_CACHE: $HF_HUB_CACHE"' >> /app/start.sh && \
144
  echo 'echo "HF_CACHE_HOME: $HF_CACHE_HOME"' >> /app/start.sh && \
145
  echo 'echo "TEMP_DIR: $TEMP_DIR"' >> /app/start.sh && \
146
+ echo 'echo "Running environment test..."' >> /app/start.sh && \
147
+ echo 'python test_permissions.py' >> /app/start.sh && \
148
  echo 'if [ $? -eq 0 ]; then' >> /app/start.sh && \
149
+ echo ' echo "Environment test passed, starting Streamlit app..."' >> /app/start.sh && \
 
150
  echo ' exec streamlit run src/streamlit_app.py --server.port=8501 --server.address=0.0.0.0' >> /app/start.sh && \
151
  echo 'else' >> /app/start.sh && \
152
+ echo ' echo "Environment test failed, exiting..."' >> /app/start.sh && \
153
  echo ' exit 1' >> /app/start.sh && \
154
  echo 'fi' >> /app/start.sh && \
155
  chmod +x /app/start.sh