commit 91750d8a5df22ce73417d8a97f5c935a7bd9dccc Author: kjuulh Date: Fri Apr 5 21:31:00 2024 +0200 feat: with plan Signed-off-by: kjuulh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..316c10c --- /dev/null +++ b/.drone.yml @@ -0,0 +1,191 @@ +kind: pipeline +name: default +type: docker + +steps: + - name: build ci + image: rustlang/rust:nightly + volumes: + - name: ci + path: /mnt/ci + environment: + PKG_CONFIG_SYSROOT_DIR: "/" + CI_PREFIX: "/mnt/ci" + commands: + - set -e + - apt update + - apt install musl-tools pkg-config libssl-dev openssl build-essential musl-dev -y + - rustup target add x86_64-unknown-linux-musl + - cargo build --target=x86_64-unknown-linux-musl -p ci --bin ci + - mv target/x86_64-unknown-linux-musl/debug/ci "$CI_PREFIX/ci" + + - name: load_secret + image: debian:buster-slim + volumes: + - name: ssh + path: /root/.ssh/ + environment: + SSH_KEY: + from_secret: gitea_id_ed25519 + commands: + - mkdir -p $HOME/.ssh/ + - echo "$SSH_KEY" | base64 -d > $HOME/.ssh/id_ed25519 + - chmod -R 600 ~/.ssh + - | + cat >$HOME/.ssh/config < eyre::Result<()> { + let client = dagger_sdk::connect().await?; + + let service = &RustService::from(client.clone()) + .with_arch(Architecture::Amd64) + .with_os(Os::Linux) + .with_apt(&[ + "clang", + "libssl-dev", + "libz-dev", + "libgit2-dev", + "git", + "openssh-client", + ]) + .with_apt_release(&["git", "openssh-client"]) + .with_docker_cli() + .with_cuddle_cli() + .with_kubectl() + .with_apt_ca_certificates() + .with_crates(["ci", "crates/*"]) + .with_mold("2.3.3") + .with_bin_name(BIN_NAME) + .with_deployment(false) + .to_owned(); + + let drone_templater = &DroneTemplater::new(client, "templates/cuddle-node-service-plan.yaml") + .with_variable("bin_name", BIN_NAME) + .to_owned(); + + CuddleCI::default() + .with_pull_request(service) + .with_main(service) + .with_main(drone_templater) + .execute(std::env::args()) + .await?; + + Ok(()) +} diff --git a/crates/cuddle-node-service-plan/.gitignore b/crates/cuddle-node-service-plan/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/crates/cuddle-node-service-plan/.gitignore @@ -0,0 +1 @@ +/target diff --git a/crates/cuddle-node-service-plan/Cargo.toml b/crates/cuddle-node-service-plan/Cargo.toml new file mode 100644 index 0000000..660fed1 --- /dev/null +++ b/crates/cuddle-node-service-plan/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "cuddle-node-service-plan" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio.workspace = true + +dagger-sdk = "0.9.8" +eyre = { version = "0.6.12" } + +dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" } +dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" } +cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" } +async-trait = "0.1.79" diff --git a/crates/cuddle-node-service-plan/src/main.rs b/crates/cuddle-node-service-plan/src/main.rs new file mode 100644 index 0000000..db77a75 --- /dev/null +++ b/crates/cuddle-node-service-plan/src/main.rs @@ -0,0 +1,23 @@ +use cuddle_ci::cuddle_file::CuddleFile; +use cuddle_ci::node_service::NodeService; +use cuddle_ci::rust_service::architecture::{Architecture, Os}; +use cuddle_ci::CuddleCI; + +#[tokio::main] +async fn main() -> eyre::Result<()> { + let client = dagger_sdk::connect().await?; + let cuddle_file = CuddleFile::from_cuddle_file().await?; + + let service = &NodeService::new(client.clone(), &cuddle_file.vars.service) + .with_arch(Architecture::Amd64) + .with_os(Os::Linux) + .to_owned(); + + CuddleCI::default() + .with_pull_request(service) + .with_main(service) + .execute(std::env::args()) + .await?; + + Ok(()) +} diff --git a/cuddle.yaml b/cuddle.yaml new file mode 100644 index 0000000..b25fe20 --- /dev/null +++ b/cuddle.yaml @@ -0,0 +1,24 @@ +# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json + +base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git" + +vars: + service: "cuddle-node-service-plan" + registry: kasperhermansen + + clusters: + clank-prod: + replicas: "3" + namespace: prod + +scripts: + render: + type: shell + args: + cluster: + name: cluster + type: flag + image_tag: + name: image_tag + type: flag + diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..7190a60 --- /dev/null +++ b/renovate.json @@ -0,0 +1,3 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json" +} diff --git a/scripts/render.sh b/scripts/render.sh new file mode 100755 index 0000000..ad2cc04 --- /dev/null +++ b/scripts/render.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -eou pipefail + +echo "rendering folder" + +cuddle render folder \ + --source $TMP/kustomize \ + --destination $TMP/rendered/kustomize \ + --extra-var cluster=$CLUSTER \ + --extra-var image_tag=$IMAGE_TAG + +echo "rendering kustomize" + +cuddle render kustomize \ + --kustomize-folder $TMP/rendered/kustomize/base \ + --destination $TMP/k8s + +echo "done" diff --git a/templates/cuddle-node-service-plan.yaml b/templates/cuddle-node-service-plan.yaml new file mode 100644 index 0000000..27ae01a --- /dev/null +++ b/templates/cuddle-node-service-plan.yaml @@ -0,0 +1,134 @@ +kind: pipeline +name: cuddle-node-service-plan +type: docker + +steps: + - name: load_secret + image: debian:buster-slim + volumes: + - name: ssh + path: /root/.ssh/ + environment: + SSH_KEY: + from_secret: gitea_id_ed25519 + commands: + - mkdir -p $HOME/.ssh/ + - echo "$SSH_KEY" | base64 -d > $HOME/.ssh/id_ed25519 + - chmod -R 600 ~/.ssh + - | + cat >$HOME/.ssh/config <