Skip to content

Commit 4ce4c0c

Browse files
committed
fix(docker): always install git in the builder for the sibling installs
1 parent ea0b47d commit 4ce4c0c

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎Dockerfile‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ ENV PIP_NO_CACHE_DIR=1 \
3838

3939
# psycopg ships binary wheels for amd64 and arm64, the two platforms this
4040
# project publishes; the remaining ones compile against libpq, which needs a
41-
# toolchain in the builder stage only -- never the runtime layer.
41+
# toolchain in the builder stage only -- never the runtime layer. git is always
42+
# required: the sibling dependencies install from git URLs, and pip shells out
43+
# to the git binary for those.
4244
RUN set -eux; \
4345
case "$TARGETPLATFORM" in \
4446
linux/amd64 | linux/arm64) \
45-
echo "binary wheels expected for $TARGETPLATFORM; skipping build tools" ;; \
46-
*) \
47-
apt-get update && apt-get install -y --no-install-recommends gcc libpq-dev \
47+
apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
4848
&& rm -rf /var/lib/apt/lists/* ;; \
49+
*) \
50+
apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
51+
gcc libpq-dev && rm -rf /var/lib/apt/lists/* ;; \
4952
esac
5053

5154
RUN python -m venv /opt/venv

‎docker/README.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ docker buildx bake --set citracker.platform=linux/amd64 --load
3333
mcpserver),与 CI 检出的 ref 相同;三者均已公开,构建无需 token。将来发布
3434
到 PyPI 后,把 `Dockerfile` 里的 git URL 换成版本钉死即可。
3535

36+
### 本地构建的代理分流
37+
38+
在本机(代理走海外节点)构建时,GitHub 要代理、阿里云镜像要直连,用
39+
`NO_PROXY` 分流,缺一不可:
40+
41+
```powershell
42+
docker build -t citracker:local `
43+
--build-arg HTTP_PROXY=http://host.docker.internal:7897 `
44+
--build-arg HTTPS_PROXY=http://host.docker.internal:7897 `
45+
--build-arg NO_PROXY=mirrors.aliyun.com,localhost,127.0.0.1,::1 .
46+
```
47+
48+
`host.docker.internal` 是从构建容器访问宿主机代理的地址(容器内的
49+
`127.0.0.1` 是它自己)。CI(Actions)网络不受此限,直接构建即可。基础镜像
50+
已本地打过标签时可完全离线构建。
51+
3652
## 镜像发布(GitHub Actions)
3753

3854
`images.yml` 由 GitHub Actions 构建并推送到阿里云镜像仓库( runners 不受

0 commit comments

Comments
 (0)