Robys01 commited on
Commit
3fcba8c
·
1 Parent(s): 634d3ae

Lets try this dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -16
Dockerfile CHANGED
@@ -1,9 +1,9 @@
1
- # Stage 1: Builder
2
- FROM python:3.12-slim AS builder
3
 
4
  WORKDIR /app
5
 
6
- # Install system build dependencies
7
  RUN apt-get update && apt-get install -y cmake g++ make build-essential && rm -rf /var/lib/apt/lists/*
8
 
9
  RUN python -m venv venv
@@ -11,23 +11,17 @@ ENV VIRTUAL_ENV=/app/venv
11
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
12
 
13
  COPY requirements.txt .
14
-
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- RUN useradd -m -u 1000 user
18
-
19
- USER user
20
 
21
- # Set home to the user's home directory
22
- ENV HOME=/home/user \
23
- PATH=/home/user/.local/bin:$PATH
24
-
25
- # Set the working directory to the user's home directory
26
- WORKDIR $HOME/app
27
 
28
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
29
- COPY --chown=user . $HOME/app
30
 
31
  EXPOSE 7860
32
-
33
  CMD ["python", "app.py"]
 
1
+ # Stage 1: Builder (using a full base image)
2
+ FROM python:3.12 AS builder
3
 
4
  WORKDIR /app
5
 
6
+ # Install build dependencies
7
  RUN apt-get update && apt-get install -y cmake g++ make build-essential && rm -rf /var/lib/apt/lists/*
8
 
9
  RUN python -m venv venv
 
11
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
12
 
13
  COPY requirements.txt .
 
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Stage 2: Runner (you can choose a slim image if the built wheels are portable)
17
+ FROM python:3.12-slim AS runner
 
18
 
19
+ WORKDIR /app
20
+ COPY --from=builder /app/venv venv
21
+ COPY --from=builder /app /app
 
 
 
22
 
23
+ ENV VIRTUAL_ENV=/app/venv
24
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
25
 
26
  EXPOSE 7860
 
27
  CMD ["python", "app.py"]