ddd
Some checks failed
Deploy control plane / Build, push, and deploy production (push) Failing after 10s
Release VPS agent / Build and publish Linux agent (push) Failing after 1m8s

This commit is contained in:
2026-09-24 23:39:54 +03:00
parent d912da6310
commit d8f98497b5
6 changed files with 53 additions and 32 deletions

7
.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
**
!agent/
!agent/Cargo.toml
!agent/Cargo.lock
!agent/Dockerfile.release
!agent/src/
!agent/src/**

View File

@@ -15,9 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45 timeout-minutes: 45
env: env:
CARGO_TERM_COLOR: always BINFMT_IMAGE: "tonistiigi/binfmt:qemu-v10.2.3-68"
RUST_TOOLCHAIN: "1.85.1"
CROSS_VERSION: "0.2.5"
steps: steps:
- name: Checkout tag - name: Checkout tag
@@ -40,7 +38,7 @@ jobs:
exit 1 exit 1
fi fi
- name: Prepare Rust and cross - name: Prepare multi-architecture builder
shell: bash shell: bash
run: | run: |
set -Eeuo pipefail set -Eeuo pipefail
@@ -50,29 +48,27 @@ jobs:
exit 1 exit 1
} }
done done
if ! command -v rustup >/dev/null || ! command -v cargo >/dev/null; then
rustup_installer="$(mktemp "${RUNNER_TEMP:-/tmp}/rustup-init.XXXXXX")"
trap 'rm -f "$rustup_installer"' EXIT
curl --proto '=https' --tlsv1.2 --fail --silent --show-error \
https://sh.rustup.rs \
--output "$rustup_installer"
sh "$rustup_installer" -y --profile minimal --default-toolchain none
export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:$PATH"
printf '%s\n' "${CARGO_HOME:-$HOME/.cargo}/bin" >> "$GITHUB_PATH"
fi
command -v rustup >/dev/null || { printf 'rustup installation failed\n' >&2; exit 1; }
command -v cargo >/dev/null || { printf 'cargo installation failed\n' >&2; exit 1; }
rustup toolchain install "$RUST_TOOLCHAIN" --profile minimal --no-self-update
rustup override set "$RUST_TOOLCHAIN"
cargo install cross --version "$CROSS_VERSION" --locked
docker info >/dev/null docker info >/dev/null
docker buildx version >/dev/null
docker run --privileged --rm "$BINFMT_IMAGE" --install arm64
docker buildx inspect --bootstrap
- name: Build static Linux binaries - name: Build static Linux binaries
shell: bash shell: bash
run: | run: |
set -Eeuo pipefail set -Eeuo pipefail
cross build --locked --release --manifest-path agent/Cargo.toml --target x86_64-unknown-linux-musl docker buildx build \
cross build --locked --release --manifest-path agent/Cargo.toml --target aarch64-unknown-linux-musl --platform linux/amd64 \
--file agent/Dockerfile.release \
--target artifact \
--output type=local,dest=build/linux-amd64 \
.
docker buildx build \
--platform linux/arm64 \
--file agent/Dockerfile.release \
--target artifact \
--output type=local,dest=build/linux-arm64 \
.
- name: Package and verify assets - name: Package and verify assets
shell: bash shell: bash
@@ -80,8 +76,8 @@ jobs:
set -Eeuo pipefail set -Eeuo pipefail
./scripts/package-agent-release.sh \ ./scripts/package-agent-release.sh \
--output dist \ --output dist \
--amd64 agent/target/x86_64-unknown-linux-musl/release/vps-agent \ --amd64 build/linux-amd64/vps-agent \
--arm64 agent/target/aarch64-unknown-linux-musl/release/vps-agent --arm64 build/linux-arm64/vps-agent
file dist/vps-agent-linux-amd64 dist/vps-agent-linux-arm64 file dist/vps-agent-linux-amd64 dist/vps-agent-linux-arm64
grep -q 'statically linked' < <(file -b dist/vps-agent-linux-amd64) grep -q 'statically linked' < <(file -b dist/vps-agent-linux-amd64)
grep -q 'statically linked' < <(file -b dist/vps-agent-linux-arm64) grep -q 'statically linked' < <(file -b dist/vps-agent-linux-arm64)

2
agent/Cargo.lock generated
View File

@@ -1095,7 +1095,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]] [[package]]
name = "vps-agent" name = "vps-agent"
version = "0.1.0" version = "0.1.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "vps-agent" name = "vps-agent"
version = "0.1.4" version = "0.1.5"
edition = "2021" edition = "2021"
rust-version = "1.80" rust-version = "1.80"
license = "Apache-2.0" license = "Apache-2.0"

16
agent/Dockerfile.release Normal file
View File

@@ -0,0 +1,16 @@
# syntax=docker/dockerfile:1.7
FROM --platform=$TARGETPLATFORM rust:1.85.1-alpine3.21 AS build
RUN apk add --no-cache musl-dev
WORKDIR /src
COPY agent/Cargo.toml agent/Cargo.lock ./
COPY agent/src ./src
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target \
cargo build --locked --release && \
install -D -m 0755 /src/target/release/vps-agent /out/vps-agent
FROM scratch AS artifact
COPY --from=build /out/vps-agent /vps-agent

View File

@@ -12,14 +12,16 @@ Register an amd64 Gitea Actions runner whose `ubuntu-latest` label resolves to a
Linux environment with: Linux environment with:
- `bash`, `curl`, `jq`, `file`, `sha256sum`, Git, and CA certificates; - `bash`, `curl`, `jq`, `file`, `sha256sum`, Git, and CA certificates;
- Docker with permission for the runner user to access its daemon; - Docker with Buildx and permission for the runner user to access its daemon;
- outbound access to the Rust registries and the container registry used by - permission to start the pinned `tonistiigi/binfmt` helper as privileged so it
`cross`. can register the arm64 emulator;
- outbound access to Docker Hub and the Rust package registry.
When Rustup or Cargo is absent, the job bootstraps Rustup using its official TLS Rust and Cargo are not required on the runner. Buildx runs the pinned official
installer. It then installs the pinned Rust 1.85.1 toolchain and `cross` 0.2.5. `rust:1.85.1-alpine3.21` image natively for amd64 and through QEMU for arm64.
`cross` uses Docker to build both musl targets; no amd64 or arm64 build host is Both resulting binaries are statically linked against musl. No amd64 or arm64
required. Do not expose the Docker daemon over an unauthenticated TCP socket. build host is required. Do not expose the Docker daemon over an unauthenticated
TCP socket.
The simplest setup is a dedicated runner VM with an `ubuntu-latest:host` label. The simplest setup is a dedicated runner VM with an `ubuntu-latest:host` label.
If jobs run inside a container instead, that container needs the Docker CLI and If jobs run inside a container instead, that container needs the Docker CLI and