Skip to content

Commit bcf4fde

Browse files
committed
3.11
1 parent f1e58f0 commit bcf4fde

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- v1
10+
release:
11+
types: [published]
12+
13+
concurrency:
14+
group: docker-blobcache-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build_image:
19+
name: Push Docker image to hub.6scloud.com
20+
runs-on: ubuntu-latest
21+
# 保持原有的权限检查,如果不是在该 organization 下运行请移除此行
22+
if: github.repository_owner == 'siliconflow'
23+
24+
steps:
25+
- name: Check out the repo
26+
uses: actions/checkout@v4
27+
28+
- name: Login to Docker Registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: hub.6scloud.com
32+
username: ${{ secrets.HUB_6S_CLOUD_USERNAME }}
33+
password: ${{ secrets.HUB_6S_CLOUD_TOKEN }}
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Get version
42+
id: get_version
43+
run: |
44+
if [[ "${{ github.event_name }}" == "release" ]]; then
45+
VERSION=${{ github.ref_name }}
46+
else
47+
# 使用前 7 位 commit hash 作为短版本号
48+
VERSION=$(echo ${{ github.sha }} | cut -c1-7)
49+
fi
50+
echo "version=$VERSION" >> $GITHUB_OUTPUT
51+
52+
- name: Build and push Docker image
53+
uses: docker/build-push-action@v5
54+
with:
55+
context: .
56+
platforms: linux/amd64
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: |
59+
hub.6scloud.com/d1r7umcsfi9c73b4drdg/blobcache:latest
60+
hub.6scloud.com/d1r7umcsfi9c73b4drdg/blobcache:${{ steps.get_version.outputs.version }}
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.13
1+
3.11

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 使用官方 Python 基础镜像
2+
FROM python:3.11-slim-bookworm AS builder
3+
4+
# 安装 uv
5+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
6+
7+
# 设置工作目录
8+
WORKDIR /app
9+
10+
# 复制依赖文件
11+
COPY pyproject.toml uv.lock ./
12+
13+
# 导出依赖并安装到系统路径(或使用虚拟环境)
14+
# --system 标志允许直接安装在镜像的 Python 环境中,适合容器场景
15+
RUN uv sync --frozen --no-dev --system
16+
17+
# 最终镜像
18+
FROM python:3.11-slim-bookworm
19+
20+
WORKDIR /app
21+
22+
# 从构建阶段复制安装好的库
23+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
24+
COPY --from=builder /usr/local/bin /usr/local/bin
25+
26+
# 复制源代码
27+
COPY . .
28+
29+
# 暴露端口
30+
EXPOSE 8000
31+
32+
# 启动命令
33+
CMD ["python", "main.py"]

0 commit comments

Comments
 (0)