noahlee1234 commited on
Commit
cbedf8b
·
1 Parent(s): 7907578

Use Miniconda in Dockerfile for reliable build123d installation

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -16
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM python:3.10-slim
2
 
3
  # Install system libraries that OpenCascade/Gradio often require
4
  RUN apt-get update && apt-get install -y \
@@ -6,27 +6,37 @@ RUN apt-get update && apt-get install -y \
6
  libglib2.0-0 \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
- WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- # Install Python requirements
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir --upgrade pip && \
14
- pip install --no-cache-dir -r requirements.txt
 
 
 
 
15
 
16
  # Create necessary directories and set permissions
17
- RUN mkdir -p artifacts/runs artifacts/logs && \
18
- chmod -R 777 artifacts
19
 
20
  # Copy the rest of the application
21
- COPY . .
22
-
23
- # Create a non-root user (Hugging Face requirement for some Docker Spaces)
24
- RUN useradd -m -u 1000 user && \
25
- chown -R user:user /app
26
- USER user
27
 
28
  # Hugging Face exposes port 7860 by default
29
  EXPOSE 7860
30
 
31
- # Run the app
32
- CMD ["python", "app.py"]
 
1
+ FROM continuumio/miniconda3:latest
2
 
3
  # Install system libraries that OpenCascade/Gradio often require
4
  RUN apt-get update && apt-get install -y \
 
6
  libglib2.0-0 \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Create a non-root user
10
+ RUN useradd -m -u 1000 user
11
+ USER user
12
+ ENV HOME=/home/user \
13
+ PATH=/home/user/.local/bin:$PATH \
14
+ CONDA_DIR=/opt/conda
15
+
16
+ WORKDIR $HOME/app
17
+
18
+ # Set up conda environment with build123d from conda-forge
19
+ RUN conda create -n cad python=3.10 -y && \
20
+ conda install -n cad -c conda-forge build123d=0.10.0 -y && \
21
+ conda clean -a -y
22
 
23
+ # We need conda in the path
24
+ ENV PATH=$CONDA_DIR/envs/cad/bin:$PATH
25
+
26
+ # Install the rest of the python requirements via pip
27
+ COPY --chown=user requirements.txt .
28
+ # Remove build123d from pip requirements since conda handles it
29
+ RUN grep -v "build123d" requirements.txt > reqs_no_cad.txt && \
30
+ $CONDA_DIR/envs/cad/bin/pip install --no-cache-dir -r reqs_no_cad.txt
31
 
32
  # Create necessary directories and set permissions
33
+ RUN mkdir -p artifacts/runs artifacts/logs
 
34
 
35
  # Copy the rest of the application
36
+ COPY --chown=user . .
 
 
 
 
 
37
 
38
  # Hugging Face exposes port 7860 by default
39
  EXPOSE 7860
40
 
41
+ # Run the app using the conda environment
42
+ CMD ["/opt/conda/envs/cad/bin/python", "app.py"]