first commit
This commit is contained in:
@@ -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
|
||||
@@ -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]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/target
|
||||
.env
|
||||
Generated
+1939
File diff suppressed because it is too large
Load Diff
+13
@@ -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
@@ -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!"
|
||||
}
|
||||
+19
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user