first commit

This commit is contained in:
2026-05-18 22:32:23 +02:00
commit 2cf50b0168
10 changed files with 2045 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
FROM debian:trixie
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=1000
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
build-essential \
cmake \
pkg-config \
clang \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd --gid ${USER_GID:-1000} $USERNAME \
&& useradd --uid ${USER_UID:-1000} --gid ${USER_GID:-1000} -m $USERNAME
USER $USERNAME
WORKDIR /home/$USERNAME
ENV PATH="/home/${USERNAME}/.cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
+19
View File
@@ -0,0 +1,19 @@
{
"name": "herald",
"build": {
"dockerfile": "Dockerfile",
"args": {
"USERNAME": "dev",
"USER_UID": "${localEnv:UID}",
"USER_GID": "${localEnv:GID}"
}
},
"remoteUser": "dev",
"containerEnv": {
"SHELL": "/bin/bash"
},
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/herald,type=bind",
"workspaceFolder": "/workspaces/herald",
"runArgs": ["--userns=keep-id", "--security-opt", "label=disable"],
"appPort": [3000]
}
+2
View File
@@ -0,0 +1,2 @@
/target
.env
Generated
+1939
View File
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
[package]
name = "herald"
version = "0.1.0"
edition = "2024"
[dependencies]
reqwest = { version = "0.13", features = ["json"] }
tokio = { version = "1.52", features = ["full"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
dotenvy = "0.15"
axum = "0.8"
anyhow = "1.0"
+17
View File
@@ -0,0 +1,17 @@
use axum::Router;
use axum::routing::get;
use crate::env;
pub async fn start_api(config: env::EnvConfig) -> anyhow::Result<()> {
let app = Router::new().route("/", get(root));
let listerner = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", config.http_port)).await?;
axum::serve(listerner, app)
.await
.map_err(|e| anyhow::anyhow!(e))
}
async fn root() -> &'static str {
"Hello, World!"
}
View File
+19
View File
@@ -0,0 +1,19 @@
use dotenvy::dotenv;
pub struct EnvConfig {
pub http_port: u16,
pub bot_name: String,
}
pub fn load_config() -> anyhow::Result<EnvConfig> {
dotenv().ok();
let http_port = std::env::var("HTTP_PORT")?.parse()?;
let bot_name = std::env::var("BOT_NAME")?;
Ok(EnvConfig {
http_port,
bot_name,
})
}
View File
+9
View File
@@ -0,0 +1,9 @@
mod api;
mod env;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = env::load_config()?;
api::start_api(config).await
}