Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dev build target #2

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 52 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 }}
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}-dev
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*