Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2302094096 | |||
| d8f98497b5 | |||
| d912da6310 | |||
| e460f0fb85 | |||
| e5d03ade52 | |||
| a56a9568f6 |
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/**
|
||||
@@ -16,7 +16,6 @@ jobs:
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
|
||||
REGISTRY_USERNAME: ${{ vars.REGISTRY_USERNAME }}
|
||||
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
||||
DEPLOY_PORT: ${{ vars.DEPLOY_PORT }}
|
||||
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
||||
@@ -32,6 +31,7 @@ jobs:
|
||||
- name: Validate deployment configuration
|
||||
shell: bash
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_SSH_KNOWN_HOSTS: ${{ secrets.DEPLOY_SSH_KNOWN_HOSTS }}
|
||||
@@ -70,6 +70,7 @@ jobs:
|
||||
- name: Login to container registry
|
||||
shell: bash
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
@@ -104,6 +105,7 @@ jobs:
|
||||
- name: Deploy on production server
|
||||
shell: bash
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_SSH_KNOWN_HOSTS: ${{ secrets.DEPLOY_SSH_KNOWN_HOSTS }}
|
||||
|
||||
@@ -15,9 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_TOOLCHAIN: "1.85.1"
|
||||
CROSS_VERSION: "0.2.5"
|
||||
BINFMT_IMAGE: "tonistiigi/binfmt:qemu-v10.2.3-68"
|
||||
|
||||
steps:
|
||||
- name: Checkout tag
|
||||
@@ -40,27 +38,37 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Prepare Rust and cross
|
||||
- name: Prepare multi-architecture builder
|
||||
shell: bash
|
||||
run: |
|
||||
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 || {
|
||||
printf 'runner prerequisite is missing: %s\n' "$command_name" >&2
|
||||
exit 1
|
||||
}
|
||||
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 buildx version >/dev/null
|
||||
docker run --privileged --rm "$BINFMT_IMAGE" --install arm64
|
||||
docker buildx inspect --bootstrap
|
||||
|
||||
- name: Build static Linux binaries
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
cross build --locked --release --manifest-path agent/Cargo.toml --target x86_64-unknown-linux-musl
|
||||
cross build --locked --release --manifest-path agent/Cargo.toml --target aarch64-unknown-linux-musl
|
||||
docker buildx build \
|
||||
--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
|
||||
shell: bash
|
||||
@@ -68,8 +76,8 @@ jobs:
|
||||
set -Eeuo pipefail
|
||||
./scripts/package-agent-release.sh \
|
||||
--output dist \
|
||||
--amd64 agent/target/x86_64-unknown-linux-musl/release/vps-agent \
|
||||
--arm64 agent/target/aarch64-unknown-linux-musl/release/vps-agent
|
||||
--amd64 build/linux-amd64/vps-agent \
|
||||
--arm64 build/linux-arm64/vps-agent
|
||||
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-arm64)
|
||||
|
||||
2
agent/Cargo.lock
generated
2
agent/Cargo.lock
generated
@@ -1095,7 +1095,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "vps-agent"
|
||||
version = "0.1.0"
|
||||
version = "0.1.6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vps-agent"
|
||||
version = "0.1.1"
|
||||
version = "0.1.6"
|
||||
edition = "2021"
|
||||
rust-version = "1.80"
|
||||
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
|
||||
@@ -16,7 +16,7 @@ Keep these existing instance-level values:
|
||||
| Kind | Name | Purpose |
|
||||
| --- | --- | --- |
|
||||
| Variable | `REGISTRY_HOST` | Registry hostname with optional port, without `https://` |
|
||||
| Variable | `REGISTRY_USERNAME` | Registry login/user name |
|
||||
| Secret | `REGISTRY_USERNAME` | Registry login/user name |
|
||||
| Secret | `REGISTRY_PASSWORD` | Gitea PAT with `write:package` access (which includes read) |
|
||||
| Secret | `RELEASE_TOKEN` | Used by the separate agent release workflow |
|
||||
|
||||
|
||||
@@ -12,14 +12,16 @@ Register an amd64 Gitea Actions runner whose `ubuntu-latest` label resolves to a
|
||||
Linux environment with:
|
||||
|
||||
- `bash`, `curl`, `jq`, `file`, `sha256sum`, Git, and CA certificates;
|
||||
- Rustup and Cargo;
|
||||
- Docker with permission for the runner user to access its daemon;
|
||||
- outbound access to the Rust registries and the container registry used by
|
||||
`cross`.
|
||||
- Docker with Buildx and permission for the runner user to access its daemon;
|
||||
- permission to start the pinned `tonistiigi/binfmt` helper as privileged so it
|
||||
can register the arm64 emulator;
|
||||
- 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`
|
||||
uses Docker to build both musl targets; no amd64 or arm64 build host is required.
|
||||
Do not expose the Docker daemon over an unauthenticated TCP socket.
|
||||
Rust and Cargo are not required on the runner. Buildx runs the pinned official
|
||||
`rust:1.85.1-alpine3.21` image natively for amd64 and through QEMU for arm64.
|
||||
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.
|
||||
If jobs run inside a container instead, that container needs the Docker CLI and
|
||||
|
||||
Reference in New Issue
Block a user