Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +21 -2
Dockerfile
CHANGED
@@ -1,8 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
FROM python:3.9-slim
|
2 |
WORKDIR /app
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
COPY entrypoint.sh /entrypoint.sh
|
6 |
RUN chmod +x /entrypoint.sh
|
|
|
7 |
EXPOSE 7860
|
8 |
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
1 |
+
#################### builder stage ####################
|
2 |
+
FROM python:3.9-slim AS builder
|
3 |
+
WORKDIR /build
|
4 |
+
|
5 |
+
COPY requirements.txt .
|
6 |
+
RUN pip install --prefix=/install -r requirements.txt
|
7 |
+
|
8 |
+
COPY app.py .
|
9 |
+
RUN python -m compileall -b -f app.py
|
10 |
+
RUN tar -C /build -czf /build/app.tgz app.pyc
|
11 |
+
|
12 |
+
#################### final stage ####################
|
13 |
FROM python:3.9-slim
|
14 |
WORKDIR /app
|
15 |
+
|
16 |
+
# 1. Install dependencies
|
17 |
+
COPY --from=builder /install /usr/local/
|
18 |
+
|
19 |
+
# 2. Copy the bytecode tarball into writable /tmp
|
20 |
+
COPY --from=builder /build/app.tgz /tmp/app.tgz
|
21 |
+
|
22 |
+
# 3. Add entrypoint
|
23 |
COPY entrypoint.sh /entrypoint.sh
|
24 |
RUN chmod +x /entrypoint.sh
|
25 |
+
|
26 |
EXPOSE 7860
|
27 |
ENTRYPOINT ["/entrypoint.sh"]
|