Add container setup scripts for various services
All checks were successful
GBCI / build (push) Successful in 8m19s

- Implemented ALM container setup with Forgejo installation and systemd service configuration.
- Created Bot container setup with necessary dependencies and Node.js application installation.
- Developed Desktop container setup with XRDP and Brave browser installation.
- Established Directory container setup with Zitadel installation and service configuration.
- Added Doc Editor container setup for Collabora Online integration.
- Implemented Drive container setup with MinIO installation and service configuration.
- Created Email container setup with Stalwart Mail installation and service configuration.
- Developed Meeting container setup with LiveKit and TURN server configuration.
- Added Proxy container setup with Caddy installation and service configuration.
- Implemented System container setup for general bots with service configuration.
- Created Table Editor container setup with NocoDB installation and service configuration.
- Developed Tables container setup with PostgreSQL installation and configuration.
- Added Webmail container setup with Roundcube installation and service configuration.
- Included prompt guidelines for container setup scripts.
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-06-30 11:15:14 -03:00
parent a80dde2e7f
commit f2bacf6ca8
4 changed files with 49 additions and 23 deletions

View file

@ -1,28 +1,21 @@
use actix_web::{middleware, web, App, HttpServer}; use actix_web::{web, App, HttpServer};
use dotenv::dotenv; use dotenv::dotenv;
use sqlx::PgPool; use sqlx::PgPool;
use tracing_subscriber::fmt::format::FmtSpan;
use services::config::*; use services::config::*;
use services::email::*;
use services::file::*; use services::file::*;
use services::state::*; use services::state::*;
use services::email::*;
mod services; mod services;
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
dotenv().ok(); dotenv().ok();
let config = AppConfig::from_env(); let config = AppConfig::from_env();
let db = PgPool::connect(&std::env::var("DATABASE_URL").unwrap())
.await
.unwrap();
tracing_subscriber::fmt() let db_url = config.database_url();
.with_span_events(FmtSpan::CLOSE) let db = PgPool::connect(&db_url).await.unwrap();
.init();
let minio_client = init_minio(&config) let minio_client = init_minio(&config)
.await .await
@ -37,8 +30,6 @@ async fn main() -> std::io::Result<()> {
// Start HTTP server // Start HTTP server
HttpServer::new(move || { HttpServer::new(move || {
App::new() App::new()
.wrap(middleware::Logger::default())
.wrap(middleware::Compress::default())
.app_data(app_state.clone()) .app_data(app_state.clone())
.service(upload_file) .service(upload_file)
.service(list_file) .service(list_file)

View file

@ -4,11 +4,22 @@ use std::env;
pub struct AppConfig { pub struct AppConfig {
pub minio: MinioConfig, pub minio: MinioConfig,
pub server: ServerConfig, pub server: ServerConfig,
pub database: DatabaseConfig,
}
#[derive(Clone)]
pub struct DatabaseConfig {
pub username: String,
pub password: String,
pub server: String,
pub port: u32,
pub database: String,
} }
#[derive(Clone)] #[derive(Clone)]
pub struct MinioConfig { pub struct MinioConfig {
pub endpoint: String, pub server: String,
pub access_key: String, pub access_key: String,
pub secret_key: String, pub secret_key: String,
pub use_ssl: bool, pub use_ssl: bool,
@ -22,25 +33,49 @@ pub struct ServerConfig {
} }
impl AppConfig { impl AppConfig {
pub fn database_url(&self) -> String {
format!(
"postgres://{}:{}@{}:{}/{}",
self.database.username,
self.database.password,
self.database.server,
self.database.port,
self.database.database
)
}
pub fn from_env() -> Self { pub fn from_env() -> Self {
let database = DatabaseConfig {
username: env::var("TABLES_USERNAME").unwrap_or_else(|_| "user".to_string()),
password: env::var("TABLES_PASSWORD").unwrap_or_else(|_| "pass".to_string()),
server: env::var("TABLES_SERVER").unwrap_or_else(|_| "localhost".to_string()),
port: env::var("TABLES_PORT")
.ok()
.and_then(|p| p.parse().ok())
.unwrap_or(5432),
database: env::var("TABLES_DATABASE").unwrap_or_else(|_| "db".to_string()),
};
let minio = MinioConfig { let minio = MinioConfig {
endpoint: env::var("MINIO_ENDPOINT").expect("MINIO_ENDPOINT not set"), server: env::var("DRIVE_SERVER").expect("DRIVE_SERVER not set"),
access_key: env::var("MINIO_ACCESS_KEY").expect("MINIO_ACCESS_KEY not set"), access_key: env::var("DRIVE_ACCESSKEY").expect("DRIVE_ACCESSKEY not set"),
secret_key: env::var("MINIO_SECRET_KEY").expect("MINIO_SECRET_KEY not set"), secret_key: env::var("DRIVE_SECRET").expect("DRIVE_SECRET not set"),
use_ssl: env::var("MINIO_USE_SSL") use_ssl: env::var("DRIVE_USE_SSL")
.unwrap_or_else(|_| "false".to_string()) .unwrap_or_else(|_| "false".to_string())
.parse() .parse()
.unwrap_or(false), .unwrap_or(false),
bucket: env::var("MINIO_BUCKET").expect("MINIO_BUCKET not set"), bucket: env::var("DRIVE_ORG_PREFIX").unwrap_or_else(|_| "".to_string()),
}; };
AppConfig { AppConfig {
minio, minio,
server: ServerConfig { server: ServerConfig {
host: env::var("SERVER_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()), host: env::var("SERVER_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()),
port: env::var("SERVER_PORT").ok() port: env::var("SERVER_PORT")
.ok()
.and_then(|p| p.parse().ok()) .and_then(|p| p.parse().ok())
.unwrap_or(8080), .unwrap_or(8080),
}, },
database,
} }
} }
} }

View file

@ -57,7 +57,7 @@ pub async fn list_emails() -> Result<web::Json<Vec<email::Email>>, actix_web::Er
} }
#[actix_web::post("/campaigns/{campaign_id}/click/{email}")] #[actix_web::get("/campaigns/{campaign_id}/click/{email}")]
pub async fn save_click( pub async fn save_click(
path: web::Path<(String, String)>, path: web::Path<(String, String)>,
state: web::Data<AppState>, state: web::Data<AppState>,

View file

@ -19,7 +19,7 @@ use crate::services::state::AppState;
pub async fn init_minio(config: &AppConfig) -> Result<MinioClient, minio::s3::error::Error> { pub async fn init_minio(config: &AppConfig) -> Result<MinioClient, minio::s3::error::Error> {
let scheme = if config.minio.use_ssl { "https" } else { "http" }; let scheme = if config.minio.use_ssl { "https" } else { "http" };
let base_url = format!("{}://{}", scheme, config.minio.endpoint); let base_url = format!("{}://{}", scheme, config.minio.server);
let base_url = BaseUrl::from_str(&base_url)?; let base_url = BaseUrl::from_str(&base_url)?;
let credentials = StaticProvider::new( let credentials = StaticProvider::new(
&config.minio.access_key, &config.minio.access_key,