Skip to content

Commit f2f0c90

Browse files
committed
docker 优化
1 parent ad36547 commit f2f0c90

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Dockerfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
FROM python:3.12-slim
1+
# Builder stage
2+
FROM python:3.12-slim-bookworm AS builder
23

3-
RUN apt-get update && apt-get install -y \
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
45
libglib2.0-0 \
56
&& rm -rf /var/lib/apt/lists/*
67

78
RUN pip install flask
89

9-
COPY wcocr.cpython-312-x86_64-linux-gnu.so /app/wcocr.cpython-312-x86_64-linux-gnu.so
10+
# Final stage
11+
FROM python:3.12-slim-bookworm
1012

11-
COPY wx /app/wx
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libglib2.0-0 \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
18+
19+
COPY --from=builder /app/wcocr.cpython-312-x86_64-linux-gnu.so /app/wcocr.cpython-312-x86_64-linux-gnu.so
20+
COPY --from=builder /app/wx /app/wx
1221

1322
COPY main.py /app/main.py
1423
COPY templates /app/templates
1524

1625
WORKDIR /app
1726

18-
CMD ["python", "main.py"]
27+
CMD ["python", "main.py"]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

0 commit comments

Comments
 (0)