From bff17f09ff9b7a2768bc2400aca690b2a96f0318 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sun, 29 Mar 2026 21:22:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96github=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E9=87=8Cdocker=E9=95=9C=E5=83=8F=E7=9A=84=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 37 +++++++++++++++++++++++++++++++---- Dockerfile.ci | 25 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe142c0..0207b23 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -448,6 +448,14 @@ jobs: Copy-Item -Recurse out dist/${{ matrix.artifact }}/web Compress-Archive -Path dist/${{ matrix.artifact }} -DestinationPath dist/${{ matrix.artifact }}.zip + - name: Upload artifact for Docker build (Linux only) + if: startsWith(matrix.target, 'x86_64-unknown-linux') || startsWith(matrix.target, 'aarch64-unknown-linux') + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: dist/${{ matrix.artifact }} + retention-days: 1 + - name: Upload to release (Unix) if: runner.os != 'Windows' uses: actions/upload-release-asset@v1 @@ -471,7 +479,9 @@ jobs: asset_content_type: application/zip build-docker: - needs: create-draft-release + needs: + - create-draft-release + - build-server name: Build Docker image runs-on: ubuntu-22.04 permissions: @@ -480,7 +490,27 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up QEMU (for multi-arch builds) + - name: Download Linux x64 artifact + uses: actions/download-artifact@v4 + with: + name: codeg-server-linux-x64 + path: artifacts/linux-x64 + + - name: Download Linux arm64 artifact + uses: actions/download-artifact@v4 + with: + name: codeg-server-linux-arm64 + path: artifacts/linux-arm64 + + - name: Prepare Docker build context + run: | + mkdir -p dist/amd64 dist/arm64 + cp artifacts/linux-x64/codeg-server dist/amd64/codeg-server + cp artifacts/linux-arm64/codeg-server dist/arm64/codeg-server + cp -r artifacts/linux-x64/web dist/web + chmod +x dist/amd64/codeg-server dist/arm64/codeg-server + + - name: Set up QEMU (for multi-arch manifest) uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -507,6 +537,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + file: Dockerfile.ci platforms: linux/amd64,linux/arm64 push: true tags: | @@ -514,8 +545,6 @@ jobs: ghcr.io/${{ github.repository }}:latest ${{ secrets.DOCKERHUB_USERNAME }}/codeg:${{ steps.version.outputs.version }} ${{ secrets.DOCKERHUB_USERNAME }}/codeg:latest - cache-from: type=gha - cache-to: type=gha,mode=max publish-release: needs: diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 0000000..bf3598f --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,25 @@ +# CI-only Dockerfile: uses pre-built binaries from build-server job +# For local builds, use the standard Dockerfile instead +FROM debian:bookworm-slim + +ARG TARGETARCH + +RUN apt-get update && apt-get install -y \ + libsqlite3-0 \ + git \ + openssh-client \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +COPY dist/${TARGETARCH}/codeg-server /usr/local/bin/codeg-server +COPY dist/web /app/web + +ENV CODEG_STATIC_DIR=/app/web +ENV CODEG_DATA_DIR=/data +ENV CODEG_PORT=3080 +ENV CODEG_HOST=0.0.0.0 + +EXPOSE 3080 +VOLUME /data + +CMD ["codeg-server"]