Skip to content

Commit 554ea32

Browse files
committed
feat: update docker structure
1 parent 2d71418 commit 554ea32

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ jobs:
222222
uses: actions/download-artifact@v4
223223
with:
224224
name: dist
225-
path: backend/src/dist
225+
path: backend/dist
226226

227227
- name: Build and push
228228
if: ${{ needs.version-info.outputs.release == 1 && needs.version-info.outputs.dev != 1 }}

Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# 构建阶段
55
FROM alpine:3.18 AS builder
66

7-
ENV VENV_PATH="/opt/venv"
87

98
# 安装构建依赖
109
RUN apk add --no-cache \
@@ -25,10 +24,10 @@ ENV PATH="/root/.local/bin:$PATH"
2524
WORKDIR /build
2625

2726
# 复制依赖文件并安装(这层会被缓存,除非依赖文件改变)
28-
COPY backend/pyproject.toml backend/uv.lock ./
27+
COPY backend/pyproject.toml backend/uv.lock requirements.txt ./
2928

3029
# 安装Python依赖
31-
RUN uv sync --frozen --no-dev && mv .venv $VENV_PATH
30+
RUN uv sync --frozen --no-dev
3231

3332
# 运行阶段
3433
FROM alpine:3.18 AS runtime
@@ -38,8 +37,7 @@ ENV LANG="C.UTF-8" \
3837
PUID=1000 \
3938
PGID=1000 \
4039
UMASK=022 \
41-
VENV_PATH="/opt/venv" \
42-
PATH="/opt/venv/bin:/root/.local/bin:$PATH"
40+
PATH="/root/.local/bin:$PATH"
4341

4442
WORKDIR /app
4543

@@ -65,10 +63,11 @@ RUN set -ex && \
6563
rm -rf /var/cache/apk/* /tmp/*
6664

6765
# 从构建阶段复制虚拟环境
68-
COPY --from=builder $VENV_PATH $VENV_PATH
66+
# COPY --from=builder $VENV_PATH $VENV_PATH
67+
COPY --from=builder .venv .venv
6968

7069
# 复制应用代码(放在最后,因为代码变更最频繁)
71-
COPY --chmod=755 backend/src/. .
70+
COPY --chmod=755 backend/src/. ./src
7271
COPY --chmod=755 entrypoint.sh /entrypoint.sh
7372

7473
ENTRYPOINT ["tini", "-g", "--", "/entrypoint.sh"]

0 commit comments

Comments
 (0)