Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
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
58 changes: 37 additions & 21 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,42 @@ jobs:
- 'build/Containerfile.*'
- name: Build controlplane Container Image
if: steps.filter.outputs.sources
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
push: false
context: .
file: build/Containerfile.controlplane
tags: localhost/blixt-controlplane:pr-${{ github.event.pull_request.number }}-${{ github.sha }}
run: |
mkdir -p target/ &&
podman build \
--userns=host \
--file build/Containerfile.controlplane \
--volume "$(pwd):/workspace" \
--volume "$(pwd)/target:$(pwd)/target/" \
--build-arg BUILD_TIMESTAMP="$(date +%s%3N)" \
--build-arg UID="0" \
--build-arg GID="0" \
--build-arg WORK_DIR="$(pwd)" \
--tag localhost/blixt-controlplane:pr-${{ github.event.pull_request.number }}-${{ github.sha }}
- name: Build dataplane Container Image
if: steps.filter.outputs.sources
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
push: false
context: .
file: build/Containerfile.dataplane
tags: localhost/blixt-dataplane:pr-${{ github.event.pull_request.number }}-${{ github.sha }}
run: |
podman build \
--userns=host \
--file build/Containerfile.dataplane \
--volume "$(pwd):/workspace" \
--volume "$(pwd)/target:$(pwd)/target/" \
--build-arg BUILD_TIMESTAMP="$(date +%s%3N)" \
--build-arg UID="0" \
--build-arg GID="0" \
--build-arg WORK_DIR="$(pwd)" \
--tag localhost/blixt-dataplane:pr-${{ github.event.pull_request.number }}-${{ github.sha }}
- name: Build udp-test-server Container Image
if: steps.filter.outputs.sources
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
push: false
context: .
file: build/Containerfile.udp-test-server
tags: localhost/blixt-udp-test-server:pr-${{ github.event.pull_request.number }}-${{ github.sha }}
run: |
podman build \
--userns=host \
--file build/Containerfile.udp-test-server \
--volume "$(pwd):/workspace" \
--volume "$(pwd)/target:$(pwd)/target/" \
--build-arg BUILD_TIMESTAMP="$(date +%s%3N)" \
--build-arg UID="0" \
--build-arg GID="0" \
--build-arg WORK_DIR="$(pwd)" \
--tag localhost/blixt-udp-test-server:pr-${{ github.event.pull_request.number }}-${{ github.sha }}
- name: Install kind and kubectl
uses: helm/kind-action@b72c923563e6e80ea66e8e8c810798cc73e97e5e # current main, includes cloud-provider-kind support
if: steps.filter.outputs.sources
Expand All @@ -95,6 +109,8 @@ jobs:
- name: Run Integration Tests
if: steps.filter.outputs.sources
run: |
# kind load broken for podman https://github.com/kubernetes-sigs/kind/issues/3945
export REGISTRY="localhost"
export TAG="pr-${{ github.event.pull_request.number }}-${{ github.sha }}"
make test.integration
sudo chown -R "$(id -u):$(id -g)" target/
make test.integration.reuse
28 changes: 22 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ clean: ## clean repo
rm $(TEST_CERTS_PATH)/{*.pem,*.csr}

.PHONY: build
build: ## Build dataplane
build:
cargo xtask build-ebpf
cargo build

build.reuse:
CARGO_HOME="$(WORK_DIR)/target" RUSTUP_HOME="$(WORK_DIR)/target" cargo xtask build-ebpf
CARGO_HOME="$(WORK_DIR)/target" RUSTUP_HOME="$(WORK_DIR)/target" cargo build

.PHONY: build.release
build.release: ## Build dataplane release
cargo xtask build-ebpf --release
Expand All @@ -88,17 +92,26 @@ CONTROLPLANE_CONTAINERFILE ?= build/Containerfile.controlplane
DATAPLANE_CONTAINERFILE ?= build/Containerfile.dataplane
UDP_SERVER_CONTAINERFILE ?= build/Containerfile.udp-test-server

UID = $(shell id -u)
GID = $(shell id -g)
WORK_DIR= $(shell pwd)
BUILD_TIMESTAMP = $(shell date +%s%3N)
CONTAINER_BUILD_ARGS = --userns=host --volume "$(WORK_DIR):/workspace" --volume "$(WORK_DIR)/target:$(WORK_DIR)/target/" \
--build-arg BUILD_TIMESTAMP="$(BUILD_TIMESTAMP)" --build-arg UID="$(UID)" --build-arg GID="$(GID)" --build-arg WORK_DIR="$(WORK_DIR)" $(BUILD_ARGS)

.PHONY: build.image.controlplane
build.image.controlplane:
$(CONTAINER_RUNTIME) build $(BUILD_ARGS) --file=$(CONTROLPLANE_CONTAINERFILE) -t $(BLIXT_CONTROLPLANE_IMAGE):$(TAG) ./

mkdir -p target/
$(CONTAINER_RUNTIME) build $(CONTAINER_BUILD_ARGS) --file=$(CONTROLPLANE_CONTAINERFILE) --tag $(BLIXT_CONTROLPLANE_IMAGE):$(TAG)
.PHONY: build.image.udp-test-server
build.image.udp-test-server:
$(CONTAINER_RUNTIME) build $(BUILD_ARGS) --file=$(UDP_SERVER_CONTAINERFILE) -t $(BLIXT_UDP_SERVER_IMAGE):$(TAG) ./
mkdir -p target/
$(CONTAINER_RUNTIME) build $(CONTAINER_BUILD_ARGS) --file=$(UDP_SERVER_CONTAINERFILE) --tag $(BLIXT_UDP_SERVER_IMAGE):$(TAG)

.PHONY: build.image.dataplane
build.image.dataplane:
$(CONTAINER_RUNTIME) build $(BUILD_ARGS) --file=$(DATAPLANE_CONTAINERFILE) -t $(BLIXT_DATAPLANE_IMAGE):$(TAG) ./
mkdir -p target/
$(CONTAINER_RUNTIME) build $(CONTAINER_BUILD_ARGS) --file=$(DATAPLANE_CONTAINERFILE) --tag $(BLIXT_DATAPLANE_IMAGE):$(TAG)

.PHONY: build.all.images
build.all.images:
Expand Down Expand Up @@ -131,7 +144,10 @@ test:
cargo test -vv --workspace --exclude tests-integration

test.integration:
cargo test --package tests-integration
cargo test --package tests-integration

test.integration.reuse:
CARGO_HOME="$(WORK_DIR)/target" RUSTUP_HOME="$(WORK_DIR)/target" cargo test --package tests-integration

.PHONY: test.gencert
test.gencert: cfssl cfssljson
Expand Down
69 changes: 44 additions & 25 deletions build/Containerfile.controlplane
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,61 @@
# Builder
# ------------------------------------------------------------------------------

FROM rust:alpine AS builder

RUN apk add --no-cache clang lld

WORKDIR /workspace

ARG PROJECT_DIR=/workspace

ARG BUILD_DIR=$PROJECT_DIR/build

COPY Cargo.toml Cargo.lock ./

COPY controlplane/ controlplane/

COPY dataplane/ dataplane/

COPY tests-integration/ tests-integration/

COPY tools/ tools/

COPY xtask/ xtask/

RUN cargo build -p controlplane --target x86_64-unknown-linux-musl
FROM debian:trixie-slim AS builder

RUN apt update \
&& apt install -y build-essential rustup

ARG UID
ARG GID
ARG WORK_DIR
RUN chown "${UID}:${GID}" ${WORK_DIR}
USER ${UID}:${GID}

ENV RUSTUP_HOME=${WORK_DIR}/target
# allow re-using of cargo downloads trough saving in target/
ENV CARGO_HOME=${WORK_DIR}/target

RUN rustup install stable \
&& rustup default stable

ARG BUILD_TIMESTAMP
WORKDIR ${WORK_DIR}

# /workspace needs to be volume mounted
# ${WORK_DIR}/target can be optionally volume mounted
RUN echo "${BUILD_TIMESTAMP}" \
&& date +%s \
&& cp -a /workspace/Cargo.toml \
/workspace/Cargo.lock \
/workspace/.cargo/ \
/workspace/controlplane/ \
/workspace/dataplane/ \
/workspace/tests-integration/ \
/workspace/tools/ \
/workspace/xtask/ \
${WORK_DIR}

RUN date +%s \
&& cargo build --package controlplane \
&& date +%s \
&& mkdir -p results/ \
&& cp target/debug/controller results/

# ------------------------------------------------------------------------------
# Image
# ------------------------------------------------------------------------------

FROM alpine:latest
FROM debian:trixie-slim

LABEL org.opencontainers.image.source=https://github.com/kubernetes-sigs/blixt

WORKDIR /

USER 1000:1000

COPY --from=builder /workspace/target/x86_64-unknown-linux-musl/debug/controller /controller
ARG WORK_DIR

COPY --from=builder ${WORK_DIR}/results/controller /controller

ENTRYPOINT [ "/controller" ]
121 changes: 55 additions & 66 deletions build/Containerfile.dataplane
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,73 @@
# Builder
# ------------------------------------------------------------------------------

FROM rust:slim-bookworm AS builder

RUN apt-get update

RUN apt-get install --yes \
build-essential \
llvm-19 \
protobuf-compiler \
pkg-config \
musl-tools \
clang \
wget \
lsb-release \
software-properties-common \
gnupg

RUN rustup default stable

RUN rustup install nightly

RUN rustup component add rust-src --toolchain nightly

RUN cargo install bpf-linker

WORKDIR /workspace

RUN rustup target add x86_64-unknown-linux-musl

ARG PROJECT_DIR=/workspace

ARG BUILD_DIR=$PROJECT_DIR/build

COPY Cargo.toml Cargo.lock ./

COPY controlplane/ controlplane/

COPY dataplane/ dataplane/

COPY tests-integration/ tests-integration/

COPY tools/ tools/

COPY xtask/ xtask/

COPY .cargo/config.toml .cargo/config.toml

# We need to tell bpf-linker where it can find LLVM's shared library file.
# Ref: https://github.com/aya-rs/rustc-llvm-proxy/blob/cbcb3c6/src/lib.rs#L48
ENV LD_LIBRARY_PATH="/usr/lib/llvm-19/lib"

ENV CC_x86_64_unknown_linux_musl="/usr/bin/clang"

ENV AR_x86_64_unknown_linux_musl="/usr/lib/llvm-19/bin/llvm-ar"

RUN cargo xtask build-ebpf

RUN RUSTFLAGS=-Ctarget-feature=+crt-static cargo build \
--workspace \
--exclude ebpf \
--package loader \
--target=x86_64-unknown-linux-musl
FROM debian:trixie-slim AS builder

RUN apt update \
&& apt install -y build-essential rustup

ARG UID
ARG GID
ARG WORK_DIR
RUN chown "${UID}:${GID}" ${WORK_DIR}
USER ${UID}:${GID}

ENV RUSTUP_HOME=${WORK_DIR}/target
# allow re-using of cargo downloads trough saving in target/
ENV CARGO_HOME=${WORK_DIR}/target

RUN rustup install stable \
&& rustup default stable

RUN rustup install nightly \
&& rustup component add rust-src --toolchain nightly \
&& cargo install bpf-linker

ARG BUILD_TIMESTAMP
WORKDIR ${WORK_DIR}

# /workspace needs to be volume mounted
# ${WORK_DIR}/target can be optionally volume mounted
RUN echo "${BUILD_TIMESTAMP}" \
&& date +%s \
&& cp -a /workspace/Cargo.toml \
/workspace/Cargo.lock \
/workspace/.cargo/ \
/workspace/controlplane/ \
/workspace/dataplane/ \
/workspace/tests-integration/ \
/workspace/tools/ \
/workspace/xtask/ \
${WORK_DIR}

RUN date +%s \
&& cargo xtask build-ebpf \
&& date +%s \
&& cargo build --package loader \
&& date +%s \
&& mkdir -p results/ \
&& cp target/debug/loader results/ \
&& cp dataplane/LICENSE.BSD-2-Clause results/ \
&& cp dataplane/LICENSE.GPL-2.0 results/

# ------------------------------------------------------------------------------
# Image
# ------------------------------------------------------------------------------

FROM alpine
FROM debian:trixie-slim

LABEL org.opencontainers.image.source=https://github.com/kubernetes-sigs/blixt

LABEL org.opencontainers.image.licenses=GPL-2.0-only,BSD-2-Clause

WORKDIR /

COPY --from=builder /workspace/target/x86_64-unknown-linux-musl/debug/loader /dataplane
ARG WORK_DIR

COPY --from=builder ${WORK_DIR}/results/LICENSE.BSD-2-Clause /LICENSE.BSD-2-Clause

COPY dataplane/LICENSE.GPL-2.0 /LICENSE.GPL-2.0
COPY --from=builder ${WORK_DIR}/results/LICENSE.GPL-2.0 /LICENSE.GPL-2.0

COPY dataplane/LICENSE.BSD-2-Clause /LICENSE.BSD-2-Clause
COPY --from=builder ${WORK_DIR}/results/loader /dataplane

ENTRYPOINT ["/dataplane"]
ENTRYPOINT ["/dataplane"]
Loading
Loading