AstraOS commited on
Commit
0dd8a54
·
verified ·
1 Parent(s): 07fa2d7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -16
Dockerfile CHANGED
@@ -1,18 +1,15 @@
1
- FROM python:3.9-slim
2
-
3
- RUN apt-get update && apt-get install -y socat && rm -rf /var/lib/apt/lists/*
4
-
5
- COPY requirements.txt .
6
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
7
-
8
- WORKDIR /app
9
  COPY . .
 
 
 
10
 
11
- EXPOSE 7860
12
-
13
- # CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
14
-
15
- COPY entrypoint.sh /entrypoint.sh
16
- RUN chmod +x /entrypoint.sh
17
-
18
- ENTRYPOINT ["/entrypoint.sh"]
 
1
+ # ---------- stage 1: build ----------
2
+ FROM python:3.9-slim AS builder
3
+ WORKDIR /src
 
 
 
 
 
4
  COPY . .
5
+ RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
6
+ # optional: compile to .pyc or a zipapp
7
+ RUN python -m compileall -b app.py
8
 
9
+ # ---------- stage 2: runtime ----------
10
+ FROM python:3.9-slim
11
+ WORKDIR /app
12
+ # bring in only what you need
13
+ COPY --from=builder /install /usr/local
14
+ COPY --from=builder /src/app.pyc ./app.pyc # byte-code only
15
+ ENTRYPOINT ["python", "app.pyc"] # or uvicorn app:app ...