releaser: run me to batch release maps
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ce59d7c947
commit
54caab67d2
2
releaser/.cargo/config.toml
Normal file
2
releaser/.cargo/config.toml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[registries.strafesnet]
|
||||||
|
index = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
1
releaser/.gitignore
vendored
Normal file
1
releaser/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
1981
releaser/Cargo.lock
generated
Normal file
1981
releaser/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
releaser/Cargo.toml
Normal file
11
releaser/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "releaser"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
submissions-api = { version = "0.2.1", features = ["internal"], default-features = false, registry = "strafesnet" }
|
||||||
|
rbx_asset = { version = "0.2.5", registry = "strafesnet" }
|
||||||
|
rust-grpc = { version = "1.0.3", registry = "strafesnet" }
|
||||||
|
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "signal"] }
|
||||||
|
tonic = "0.12.3"
|
24
releaser/Containerfile
Normal file
24
releaser/Containerfile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Using the `rust-musl-builder` as base image, instead of
|
||||||
|
# the official Rust toolchain
|
||||||
|
FROM docker.io/clux/muslrust:stable AS chef
|
||||||
|
USER root
|
||||||
|
RUN cargo install cargo-chef
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
FROM chef AS planner
|
||||||
|
COPY . .
|
||||||
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
|
FROM chef AS builder
|
||||||
|
COPY --from=planner /app/recipe.json recipe.json
|
||||||
|
|
||||||
|
# Notice that we are specifying the --target flag!
|
||||||
|
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
|
||||||
|
COPY . .
|
||||||
|
RUN cargo build --release --target x86_64-unknown-linux-musl --bin releaser
|
||||||
|
|
||||||
|
FROM docker.io/alpine:latest AS runtime
|
||||||
|
RUN addgroup -S myuser && adduser -S myuser -G myuser
|
||||||
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/releaser /usr/local/bin/
|
||||||
|
USER myuser
|
||||||
|
ENTRYPOINT ["/usr/local/bin/releaser"]
|
32
releaser/src/main.rs
Normal file
32
releaser/src/main.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum StartupError{
|
||||||
|
API(submissions_api::ReqwestError),
|
||||||
|
GRPCConnect(tonic::transport::Error),
|
||||||
|
}
|
||||||
|
impl std::fmt::Display for StartupError{
|
||||||
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
|
write!(f,"{self:?}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::error::Error for StartupError{}
|
||||||
|
|
||||||
|
// annoying mile-long type
|
||||||
|
pub type MapsServiceClient=rust_grpc::maps::maps_service_client::MapsServiceClient<tonic::transport::channel::Channel>;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main()->Result<(),StartupError>{
|
||||||
|
// maps-service api
|
||||||
|
let api_host=std::env::var("API_HOST").expect("API_HOST env required");
|
||||||
|
let api=submissions_api::internal::Context::new(api_host).map_err(StartupError::API)?;
|
||||||
|
|
||||||
|
// data-service grpc for creating map entries
|
||||||
|
let data_host=std::env::var("DATA_HOST").expect("DATA_HOST env required");
|
||||||
|
let maps_grpc=crate::MapsServiceClient::connect(data_host).await.map_err(StartupError::GRPCConnect)?;
|
||||||
|
|
||||||
|
// request maps pending release
|
||||||
|
// randomize list
|
||||||
|
// release maps
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user