diff --git a/Cargo.toml b/Cargo.toml index 8c468bf059d5..80ec36fb03c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/ci/scripts/docker.sh b/ci/scripts/docker.sh index a909b7c6a37c..e3080cff326a 100755 --- a/ci/scripts/docker.sh +++ b/ci/scripts/docker.sh @@ -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 @@ -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 \ diff --git a/ci/scripts/multi-arch-docker.sh b/ci/scripts/multi-arch-docker.sh index 012378347ba2..05c4a1de36e6 100755 --- a/ci/scripts/multi-arch-docker.sh +++ b/ci/scripts/multi-arch-docker.sh @@ -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" diff --git a/ci/workflows/docker-arm-fast.yml b/ci/workflows/docker-arm-fast.yml new file mode 100644 index 000000000000..321d1e4181e0 --- /dev/null +++ b/ci/workflows/docker-arm-fast.yml @@ -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 diff --git a/docker/Dockerfile b/docker/Dockerfile index dafee4cdc68d..411396b98a99 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -63,6 +63,9 @@ 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 @@ -70,11 +73,11 @@ 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