AstraOS commited on
Commit
a69ec7f
·
verified ·
1 Parent(s): 57a39f3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -9
Dockerfile CHANGED
@@ -1,18 +1,31 @@
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
7
- RUN tar -C /build -cf /build/app.tgz app.pyc
8
 
9
- # ---------- runtime ----------
 
 
 
 
 
 
 
 
 
 
 
10
  FROM python:3.9-slim
11
  WORKDIR /app
12
- COPY --from=builder /install /usr/local/
13
- COPY --from=builder /build/app.tgz ./app.tgz
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"]
 
1
+ ######################## builder stage ########################
2
  FROM python:3.9-slim AS builder
3
  WORKDIR /build
 
 
 
 
4
 
5
+ # --- install dependencies into /install ---
6
+ COPY requirements.txt .
7
+ RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
8
+
9
+ # --- copy source and compile to byte-code ---
10
+ COPY app.py .
11
+ RUN python -m compileall -b -f app.py # produces /build/app.pyc
12
+
13
+ # --- pack the .pyc into a gzip tarball ---
14
+ RUN tar -C /build -czf /build/app.tgz app.pyc
15
+
16
+ ######################## runtime stage ########################
17
  FROM python:3.9-slim
18
  WORKDIR /app
 
 
19
 
20
+ # 1) bring in site-packages from builder
21
+ COPY --from=builder /install /usr/local/
22
+
23
+ # 2) bring in the compressed payload only
24
+ COPY --from=builder /build/app.tgz ./app.tgz
25
+
26
+ # 3) entry-point that unpacks → runs → deletes
27
  COPY entrypoint.sh /entrypoint.sh
28
  RUN chmod +x /entrypoint.sh
29
+
30
+ EXPOSE 7860
31
  ENTRYPOINT ["/entrypoint.sh"]