Spaces:
Sleeping
Sleeping
tiffank1802 commited on
Commit ·
09c4d3b
1
Parent(s): b286809
Move migrations to runtime via entrypoint script
Browse files- Dockerfile +8 -8
- entrypoint.sh +16 -0
Dockerfile
CHANGED
|
@@ -9,6 +9,7 @@ WORKDIR /app
|
|
| 9 |
# Install system dependencies
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
wget \
|
|
|
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
# Install Miniconda for FEniCS
|
|
@@ -26,9 +27,9 @@ RUN conda config --remove channels defaults || true && \
|
|
| 26 |
# Install FEniCS via conda-forge only
|
| 27 |
RUN conda install fenics-dolfinx mpich petsc4py -y && conda clean -afy
|
| 28 |
|
| 29 |
-
# Install Python dependencies
|
| 30 |
COPY requirements.txt .
|
| 31 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 32 |
|
| 33 |
# Copy application files
|
| 34 |
COPY backend/ ./backend/
|
|
@@ -38,13 +39,12 @@ COPY DangVan/ ./DangVan/
|
|
| 38 |
# Create directories for results and database
|
| 39 |
RUN mkdir -p /app/backend/simulation_results && chmod 777 /app/backend/simulation_results
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
-
RUN
|
| 44 |
-
RUN python manage.py collectstatic --noinput
|
| 45 |
|
| 46 |
# HF Spaces uses port 7860
|
| 47 |
EXPOSE 7860
|
| 48 |
|
| 49 |
-
# Run
|
| 50 |
-
CMD ["
|
|
|
|
| 9 |
# Install system dependencies
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
wget \
|
| 12 |
+
bash \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
# Install Miniconda for FEniCS
|
|
|
|
| 27 |
# Install FEniCS via conda-forge only
|
| 28 |
RUN conda install fenics-dolfinx mpich petsc4py -y && conda clean -afy
|
| 29 |
|
| 30 |
+
# Install Python dependencies (use conda's pip)
|
| 31 |
COPY requirements.txt .
|
| 32 |
+
RUN /opt/conda/bin/pip install --no-cache-dir -r requirements.txt
|
| 33 |
|
| 34 |
# Copy application files
|
| 35 |
COPY backend/ ./backend/
|
|
|
|
| 39 |
# Create directories for results and database
|
| 40 |
RUN mkdir -p /app/backend/simulation_results && chmod 777 /app/backend/simulation_results
|
| 41 |
|
| 42 |
+
# Copy entrypoint script
|
| 43 |
+
COPY entrypoint.sh /app/entrypoint.sh
|
| 44 |
+
RUN chmod +x /app/entrypoint.sh
|
|
|
|
| 45 |
|
| 46 |
# HF Spaces uses port 7860
|
| 47 |
EXPOSE 7860
|
| 48 |
|
| 49 |
+
# Run entrypoint (handles migrations and starts server)
|
| 50 |
+
CMD ["/app/entrypoint.sh"]
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
# Activate conda environment
|
| 5 |
+
source /opt/conda/etc/profile.d/conda.sh
|
| 6 |
+
conda activate base
|
| 7 |
+
|
| 8 |
+
# Run migrations
|
| 9 |
+
cd /app/backend
|
| 10 |
+
python manage.py migrate --noinput
|
| 11 |
+
|
| 12 |
+
# Collect static files (if not already done)
|
| 13 |
+
python manage.py collectstatic --noinput --clear
|
| 14 |
+
|
| 15 |
+
# Start gunicorn
|
| 16 |
+
exec gunicorn --bind 0.0.0.0:7860 --workers 2 --timeout 120 backend.wsgi:application
|