AstraOS commited on
Commit
53cf95f
Β·
verified Β·
1 Parent(s): d30162a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -10
Dockerfile CHANGED
@@ -1,15 +1,24 @@
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
15
- ENTRYPOINT ["python", "app.pyc"]
 
 
 
 
 
 
1
+ # ─────────────── builder stage ───────────────
2
  FROM python:3.9-slim AS builder
3
+ WORKDIR /build
4
+
5
+ # app + deps
6
+ COPY requirements.txt .
7
  RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
8
+ COPY app.py .
9
+
10
+ # compile to plain app.pyc in the same dir
11
+ RUN python -m compileall -b -f app.py # β†’ /build/app.pyc
12
 
13
+ # ─────────────── runtime stage ───────────────
14
  FROM python:3.9-slim
15
  WORKDIR /app
16
+
17
+ # 1) bring the site-packages that were installed into /install
18
+ COPY --from=builder /install /usr/local/
19
+
20
+ # 2) copy only the compiled byte-code
21
+ COPY --from=builder /build/app.pyc ./app.pyc
22
+
23
+ # 3) nothing else to see β€” no source
24
+ ENTRYPOINT ["python", "/app/app.pyc"]