Skip to content

Commit f56c434

Browse files
committed
Resolve the issue of re pull image
1 parent a14f48b commit f56c434

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

.github/workflows/docker-publish.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,23 @@ jobs:
9191
with:
9292
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
9393

94-
- name: Build and push Docker image
94+
# Build and export wheels directly (fastest method)
95+
- name: Build and export wheels
96+
uses: docker/build-push-action@v5
97+
with:
98+
context: .
99+
target: wheels # We'll add this target to Dockerfile
100+
outputs: type=local,dest=./out
101+
cache-from: type=local,src=/tmp/.buildx-cache
102+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
103+
104+
# Build and push the complete image (main stage)
105+
- name: Build and push Docker image
95106
id: build-and-push
96107
uses: docker/build-push-action@v5
97108
with:
98109
context: .
110+
target: main # 构建主阶段(完整可用镜像)
99111
push: ${{ github.event_name != 'pull_request' }}
100112
tags: ${{ steps.meta.outputs.tags }}
101113
labels: ${{ steps.meta.outputs.labels }}
@@ -109,16 +121,11 @@ jobs:
109121
DIGEST: ${{ steps.build-and-push.outputs.digest }}
110122
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
111123

112-
- name: Export wheel from image
124+
- name: Verify exported wheels
113125
run: |
114-
CONTAINER_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
115-
CONTAINER_ID=$(docker create $CONTAINER_TAG)
116-
# Copy wheel files from the container to the local machine
117-
docker cp "$CONTAINER_ID:/out" ./out
118-
# Remove the container
119-
docker rm "$CONTAINER_ID"
120-
# Verify wheel file has been copied
121-
ls ./out
126+
echo "Wheel files exported directly during build:"
127+
ls -la ./out/
128+
echo "Wheel count: $(ls -1 ./out/*.whl | wc -l)"
122129
123130
- name: Upload .whl to GitHub Release
124131
if: startsWith(github.ref, 'refs/tags/')

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG CUDA_VERSION=12.6.1
2-
FROM nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu22.04
2+
FROM nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu22.04 as main
33
ARG PYTHON_VERSION=3.10
44
ARG MAMBA_VERSION=24.7.1-0
55
ARG TARGETPLATFORM
@@ -91,4 +91,10 @@ RUN echo "📦 Using prebuilt flash_attn_3 wheel..." && \
9191
# cp dist/*.whl /out/ && \
9292
# echo "✅ flash_attn_3 build completed"
9393

94-
# Verify all wheels are built
94+
# Install the built wheels (ready-to-use image)
95+
RUN pip install /out/*.whl && \
96+
echo "✅ All wheels installed and ready to use"
97+
98+
# Export stage for GitHub Actions (allows direct wheel extraction)
99+
FROM scratch as wheels
100+
COPY --from=main /out/*.whl /

0 commit comments

Comments
 (0)