Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2302094096 | |||
| d8f98497b5 | |||
| d912da6310 |
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
**
|
||||||
|
!agent/
|
||||||
|
!agent/Cargo.toml
|
||||||
|
!agent/Cargo.lock
|
||||||
|
!agent/Dockerfile.release
|
||||||
|
!agent/src/
|
||||||
|
!agent/src/**
|
||||||
@@ -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,27 +38,37 @@ 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
|
||||||
for command_name in cargo rustup docker curl jq file sha256sum; do
|
for command_name in docker curl jq file sha256sum; do
|
||||||
command -v "$command_name" >/dev/null || {
|
command -v "$command_name" >/dev/null || {
|
||||||
printf 'runner prerequisite is missing: %s\n' "$command_name" >&2
|
printf 'runner prerequisite is missing: %s\n' "$command_name" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
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
|
||||||
@@ -68,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
2
agent/Cargo.lock
generated
@@ -1095,7 +1095,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vps-agent"
|
name = "vps-agent"
|
||||||
version = "0.1.0"
|
version = "0.1.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vps-agent"
|
name = "vps-agent"
|
||||||
version = "0.1.3"
|
version = "0.1.6"
|
||||||
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
16
agent/Dockerfile.release
Normal 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
|
||||||
@@ -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;
|
||||||
- Rustup and Cargo;
|
- Docker with Buildx and permission for the runner user to access its daemon;
|
||||||
- Docker with permission for the runner user to access its daemon;
|
- permission to start the pinned `tonistiigi/binfmt` helper as privileged so it
|
||||||
- outbound access to the Rust registries and the container registry used by
|
can register the arm64 emulator;
|
||||||
`cross`.
|
- outbound access to Docker Hub and the Rust package registry.
|
||||||
|
|
||||||
The job installs the pinned Rust 1.85.1 toolchain and `cross` 0.2.5. `cross`
|
Rust and Cargo are not required on the runner. Buildx runs the pinned official
|
||||||
uses Docker to build both musl targets; no amd64 or arm64 build host is required.
|
`rust:1.85.1-alpine3.21` image natively for amd64 and through QEMU for arm64.
|
||||||
Do not expose the Docker daemon over an unauthenticated TCP socket.
|
Both resulting binaries are statically linked against musl. No amd64 or arm64
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user