diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dfddbb4..7d2ee11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,26 +56,48 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push by digest - id: build + - name: Build and push runtime by digest + id: build-runtime uses: docker/build-push-action@v6 with: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} + target: runtime outputs: type=image,name=${{ env.GHCR_REPO }},push-by-digest=true,name-canonical=true,push=true build-args: | VERSION=${{ env.VERSION }} - - name: Export digest + - name: Build and push dev by digest + id: build-dev + uses: docker/build-push-action@v6 + with: + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + target: dev + outputs: type=image,name=${{ env.GHCR_REPO }},push-by-digest=true,name-canonical=true,push=true + build-args: | + VERSION=${{ env.VERSION }} + - name: Export digests run: | - mkdir -p ${{ runner.temp }}/digests - digest="${{ steps.build.outputs.digest }}" - touch "${{ runner.temp }}/digests/${digest#sha256:}" + mkdir -p ${{ runner.temp }}/digests/runtime + mkdir -p ${{ runner.temp }}/digests/dev + digest_runtime="${{ steps.build-runtime.outputs.digest }}" + digest_dev="${{ steps.build-dev.outputs.digest }}" + touch "${{ runner.temp }}/digests/runtime/${digest_runtime#sha256:}" + touch "${{ runner.temp }}/digests/dev/${digest_dev#sha256:}" - - name: Upload digest + - name: Upload runtime digest uses: actions/upload-artifact@v4 with: - name: digests-${{ env.PLATFORM_PAIR }} - path: ${{ runner.temp }}/digests/* + name: digests-runtime-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/runtime/* + if-no-files-found: error + retention-days: 1 + + - name: Upload dev digest + uses: actions/upload-artifact@v4 + with: + name: digests-dev-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/dev/* if-no-files-found: error retention-days: 1 @@ -84,11 +106,18 @@ jobs: needs: - build steps: - - name: Download digests + - name: Download runtime digests uses: actions/download-artifact@v4 with: - path: ${{ runner.temp }}/digests - pattern: digests-* + path: ${{ runner.temp }}/digests/runtime + pattern: digests-runtime-* + merge-multiple: true + + - name: Download dev digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests/dev + pattern: digests-dev-* merge-multiple: true - name: Login to GHCR @@ -112,12 +141,19 @@ jobs: type=ref,event=pr type=ref,event=tag - - name: Create manifest list and push - working-directory: ${{ runner.temp }}/digests + - name: Create runtime manifest list and push + working-directory: ${{ runner.temp }}/digests/runtime run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) - - name: Inspect image + - name: Create dev manifest list and push + working-directory: ${{ runner.temp }}/digests/dev + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + . + "-dev") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) + + - name: Inspect images run: | - docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }} \ No newline at end of file + docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}-dev diff --git a/Dockerfile b/Dockerfile index 575c27c..cb15e70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,18 @@ RUN apt-get update && apt-get install -y cmake clang ARG VERSION=main RUN git clone --depth=1 --branch ${VERSION} https://github.com/MystenLabs/sui -WORKDIR "$WORKDIR/sui" +WORKDIR /sui ARG PROFILE=release RUN cargo build --profile ${PROFILE} --bin sui -# Production Image FROM debian:bullseye-slim AS runtime RUN apt-get update && apt-get install -y ca-certificates curl -WORKDIR "$WORKDIR/sui" +WORKDIR /sui COPY --from=builder /sui/target/release/sui /usr/local/bin + +# Development Image +FROM runtime AS dev +RUN apt-get update && \ + apt-get install -yq ca-certificates curl git && \ + rm -rf /var/lib/apt/lists/*