Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +12 -18
Dockerfile
CHANGED
@@ -1,24 +1,18 @@
|
|
1 |
-
#
|
2 |
FROM python:3.9-slim AS builder
|
3 |
WORKDIR /build
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
#
|
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 |
-
#
|
18 |
-
COPY
|
19 |
-
|
20 |
-
|
21 |
-
COPY --from=builder /build/app.pyc ./app.pyc
|
22 |
-
|
23 |
-
# 3) nothing else to see β no source
|
24 |
-
ENTRYPOINT ["python", "/app/app.pyc"]
|
|
|
1 |
+
# ---------- builder ----------
|
2 |
FROM python:3.9-slim AS builder
|
3 |
WORKDIR /build
|
4 |
+
COPY app.py requirements.txt .
|
5 |
+
RUN pip install --prefix=/install -r requirements.txt
|
6 |
+
RUN python -m compileall -b -f app.py # β /build/app.pyc
|
7 |
+
RUN tar -C /build -cf /build/app.tgz app.pyc # tiny payload β¬
οΈ
|
8 |
|
9 |
+
# ---------- runtime ----------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
FROM python:3.9-slim
|
11 |
WORKDIR /app
|
12 |
+
COPY --from=builder /install /usr/local/ # deps
|
13 |
+
COPY --from=builder /build/app.tgz ./app.tgz # byte-code, archived
|
14 |
|
15 |
+
# entrypoint will unpack into /tmp, run, then delete
|
16 |
+
COPY entrypoint.sh /entrypoint.sh
|
17 |
+
RUN chmod +x /entrypoint.sh
|
18 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
|
|
|
|