-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (43 loc) · 1.26 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (43 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
ARG PYTHON_VERSION=3.12.7
ARG UV_VERSION=0.11.21
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv
FROM python:${PYTHON_VERSION}-slim-bookworm AS base
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8
## PYTHON
# Seems to speed things up
ENV PYTHONUNBUFFERED=1
# Turns off writing .pyc files. Superfluous on an ephemeral container.
ENV PYTHONDONTWRITEBYTECODE=1
# Ensures that the Python executable used
# in the image will be those from our virtualenv.
ENV PATH="/venv/bin:$PATH"
FROM base AS builder
COPY --from=uv /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PROJECT_ENVIRONMENT=/venv
WORKDIR /app
# Install OS package dependencies.
# Do all of this in one RUN to limit final image size.
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc gettext && \
rm -rf /var/lib/apt/lists/*
COPY pyproject.toml uv.lock ./
RUN uv sync --locked --no-dev --no-install-project
FROM base AS base-app
# 安装运行时依赖
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
gettext curl vim && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
USER root
ADD ./ ./
# 拷贝构件
COPY --from=builder /venv /venv
FROM base-app AS app
ENTRYPOINT ["scripts/docker-entrypoint.sh"]