Skip to content

Commit

Permalink
feat(ci): add fast-docker-build-arm workflow (#18124)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel authored Aug 20, 2024
1 parent e6e1f48 commit 281a696
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ incremental = true
split-debuginfo = "packed"
lto = "off"

# Patch profile for production clusters.
# It will trade-off lto for faster build time.
[profile.patch-production]
inherits = "production"
debug = "full"
incremental = false
split-debuginfo = "packed"
lto = "off"

[profile.production]
inherits = "release"
incremental = false
Expand Down
6 changes: 5 additions & 1 deletion ci/scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -euo pipefail
ghcraddr="ghcr.io/risingwavelabs/risingwave"
dockerhubaddr="risingwavelabs/risingwave"
arch="$(uname -m)"
CARGO_PROFILE=${CARGO_PROFILE:-production}

echo "--- ghcr login"
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin
Expand All @@ -23,12 +24,15 @@ fi

# Build RisingWave docker image ${BUILDKITE_COMMIT}-${arch}
echo "--- docker build and tag"
echo "CARGO_PROFILE is set to ${CARGO_PROFILE}"
docker buildx create \
--name container \
--driver=docker-container

docker buildx build -f docker/Dockerfile \
--build-arg "GIT_SHA=${BUILDKITE_COMMIT}" -t "${ghcraddr}:${BUILDKITE_COMMIT}-${arch}" \
--build-arg "GIT_SHA=${BUILDKITE_COMMIT}" \
--build-arg "CARGO_PROFILE=${CARGO_PROFILE}" \
-t "${ghcraddr}:${BUILDKITE_COMMIT}-${arch}" \
--progress plain \
--builder=container \
--load \
Expand Down
2 changes: 2 additions & 0 deletions ci/scripts/multi-arch-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if [ "${SKIP_TARGET_AARCH64:-false}" != "true" ]; then
arches+=("aarch64")
fi

echo "--- arches: ${arches[*]}"

# push images to gchr
function pushGchr() {
GHCRTAG="${ghcraddr}:$1"
Expand Down
33 changes: 33 additions & 0 deletions ci/workflows/docker-arm-fast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
auto-retry: &auto-retry
automatic:
# Agent terminated because the AWS EC2 spot instance killed by AWS.
- signal_reason: agent_stop
limit: 3

steps:
- label: "docker-build-push: aarch64"
if: build.env("SKIP_TARGET_AARCH64") != "true"
command: "CARGO_PROFILE=patch-production ci/scripts/docker.sh"
key: "build-aarch64"
plugins:
- seek-oss/aws-sm#v2.3.1:
env:
GHCR_USERNAME: ghcr-username
GHCR_TOKEN: ghcr-token
DOCKER_TOKEN: docker-token
GITHUB_TOKEN: github-token
agents:
queue: "linux-arm64"
retry: *auto-retry

- label: "multi-arch-image-create-push"
command: "SKIP_TARGET_AMD64=true ci/scripts/multi-arch-docker.sh"
depends_on:
- "build-aarch64"
plugins:
- seek-oss/aws-sm#v2.3.1:
env:
GHCR_USERNAME: ghcr-username
GHCR_TOKEN: ghcr-token
DOCKER_TOKEN: docker-token
retry: *auto-retry
11 changes: 7 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ FROM rust-base AS rust-builder
ARG GIT_SHA
ENV GIT_SHA=$GIT_SHA

ARG CARGO_PROFILE
ENV CARGO_PROFILE=$CARGO_PROFILE

COPY ./ /risingwave
WORKDIR /risingwave

ENV ENABLE_BUILD_DASHBOARD=1
ENV OPENSSL_STATIC=1

RUN cargo fetch && \
cargo build -p risingwave_cmd_all --profile production --features "rw-static-link" --features all-udf && \
cargo build -p risingwave_cmd_all --profile ${CARGO_PROFILE} --features "rw-static-link" --features all-udf && \
mkdir -p /risingwave/bin && \
mv /risingwave/target/production/risingwave /risingwave/bin/ && \
mv /risingwave/target/production/risingwave.dwp /risingwave/bin/ && \
cp ./target/production/build/tikv-jemalloc-sys-*/out/build/bin/jeprof /risingwave/bin/ && \
mv /risingwave/target/${CARGO_PROFILE}/risingwave /risingwave/bin/ && \
mv /risingwave/target/${CARGO_PROFILE}/risingwave.dwp /risingwave/bin/ && \
cp ./target/${CARGO_PROFILE}/build/tikv-jemalloc-sys-*/out/build/bin/jeprof /risingwave/bin/ && \
chmod +x /risingwave/bin/jeprof && \
mkdir -p /risingwave/lib && cargo clean

Expand Down

0 comments on commit 281a696

Please sign in to comment.