mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-12 08:05:44 +00:00
improve docker-compose and email sending
This commit is contained in:
@@ -304,6 +304,7 @@ the instances using their emails, configure the SMTP env variables in the
|
||||
servers:
|
||||
|
||||
```
|
||||
SMTP_FROM=noreply@windmill.dev
|
||||
SMTP_HOST=smtp.gmail.com
|
||||
SMTP_PORT=587
|
||||
SMTP_USERNAME=ruben@windmill.dev
|
||||
@@ -379,6 +380,7 @@ it being synced automatically everyday.
|
||||
| HTTP_PROXY | None | http_proxy | Server + Worker |
|
||||
| HTTPS_PROXY | None | https_proxy | Server + Worker |
|
||||
| NO_PROXY | None | no_proxy | Server + Worker |
|
||||
| SMTP_FROM | None | the address to use as the from field for emails send | Server |
|
||||
| SMTP_HOST | None | host for the smtp server to send invite emails | Server |
|
||||
| SMTP_PORT | 587 | port for the smtp server to send invite emails | Server |
|
||||
| SMTP_USERNAME | None | username for the smtp server to send invite emails | Server |
|
||||
|
||||
+4
-1
@@ -27,7 +27,7 @@ use windmill_worker::{
|
||||
};
|
||||
|
||||
const GIT_VERSION: &str = git_version!(args = ["--tag", "--always"], fallback = "unknown-version");
|
||||
const DEFAULT_NUM_WORKERS: usize = 3;
|
||||
const DEFAULT_NUM_WORKERS: usize = 1;
|
||||
const DEFAULT_PORT: u16 = 8000;
|
||||
const DEFAULT_SERVER_BIND_ADDR: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 0);
|
||||
|
||||
@@ -45,6 +45,9 @@ async fn main() -> anyhow::Result<()> {
|
||||
.and_then(|x| x.parse::<i32>().ok())
|
||||
.unwrap_or(DEFAULT_NUM_WORKERS as i32);
|
||||
|
||||
if num_workers > 1 {
|
||||
tracing::warn!("We recommend using at most 1 worker per container, use more only if you know what you are doing.");
|
||||
}
|
||||
let metrics_addr: Option<SocketAddr> = *METRICS_ADDR;
|
||||
|
||||
let server_mode = !std::env::var("DISABLE_SERVER")
|
||||
|
||||
@@ -107,6 +107,8 @@ lazy_static::lazy_static! {
|
||||
}
|
||||
};
|
||||
|
||||
pub static ref SMTP_FROM: String = std::env::var("SMTP_FROM").unwrap_or_else(|_| "noreply@getwindmill.com".to_string());
|
||||
|
||||
pub static ref LICENSE_KEY: Option<String> = std::env::var("LICENSE_KEY").ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
utils::require_super_admin,
|
||||
webhook_util::{InstanceEvent, WebhookShared},
|
||||
workspaces::invite_user_to_all_auto_invite_worspaces,
|
||||
BASE_URL, COOKIE_DOMAIN, IS_SECURE, SMTP_CLIENT,
|
||||
BASE_URL, COOKIE_DOMAIN, IS_SECURE, SMTP_CLIENT, SMTP_FROM,
|
||||
};
|
||||
use argon2::{password_hash::SaltString, Argon2, PasswordHash, PasswordHasher, PasswordVerifier};
|
||||
use axum::{
|
||||
@@ -1236,16 +1236,6 @@ async fn add_user_to_workspace<'c>(
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
send_email_if_possible(
|
||||
&format!("Added to Windmill's workspace: {w_id}"),
|
||||
&format!(
|
||||
"You have been granted access to Windmill's workspace {w_id}
|
||||
|
||||
If you do not have an account on {}, login with SSO or ask an admin to create an account for you.",
|
||||
*BASE_URL
|
||||
),
|
||||
&email,
|
||||
);
|
||||
Ok(tx)
|
||||
}
|
||||
|
||||
@@ -1470,7 +1460,7 @@ pub fn send_email_if_possible(subject: &str, content: &str, to: &str) {
|
||||
pub async fn send_email_if_possible_intern(subject: &str, content: &str, to: &str) -> Result<()> {
|
||||
if let Some(ref smtp) = *SMTP_CLIENT {
|
||||
let message = MessageBuilder::new()
|
||||
.from(("Windmill", "noreply@getwindmill.com"))
|
||||
.from(("Windmill", SMTP_FROM.as_str()))
|
||||
.to(to)
|
||||
.subject(subject)
|
||||
.text_body(content);
|
||||
@@ -1480,6 +1470,7 @@ pub async fn send_email_if_possible_intern(subject: &str, content: &str, to: &st
|
||||
.send(message)
|
||||
.await
|
||||
.map_err(to_anyhow)?;
|
||||
tracing::info!("Sent email to {to}: {subject}");
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -1043,7 +1043,7 @@ If you do not have an account on {}, login with SSO or ask an admin to create an
|
||||
}
|
||||
|
||||
async fn add_user(
|
||||
Authed { username, is_admin, .. }: Authed,
|
||||
Authed { username, email, is_admin, .. }: Authed,
|
||||
Extension(db): Extension<DB>,
|
||||
Extension(webhook): Extension<WebhookShared>,
|
||||
Path(w_id): Path<String>,
|
||||
@@ -1084,6 +1084,17 @@ async fn add_user(
|
||||
|
||||
tx.commit().await?;
|
||||
|
||||
send_email_if_possible(
|
||||
&format!("Added to Windmill's workspace: {w_id}"),
|
||||
&format!(
|
||||
"You have been granted access to Windmill's workspace {w_id} by {email}
|
||||
|
||||
If you do not have an account on {}, login with SSO or ask an admin to create an account for you.",
|
||||
*BASE_URL
|
||||
),
|
||||
&nu.email,
|
||||
);
|
||||
|
||||
webhook.send_instance_event(InstanceEvent::UserAddedWorkspace {
|
||||
workspace: w_id.clone(),
|
||||
email: nu.email.clone(),
|
||||
|
||||
@@ -53,6 +53,8 @@ services:
|
||||
- DATABASE_URL=postgres://postgres:${DB_PASSWORD}@db/windmill?sslmode=disable
|
||||
- BASE_URL=${WM_BASE_URL}
|
||||
- RUST_LOG=info
|
||||
# DO NOT INCREASE NUM_WORKERS > 1 UNLESS YOU KNOW WHAT YOU ARE DOING
|
||||
# Increase the number of replicas instead.
|
||||
- NUM_WORKERS=1
|
||||
- DISABLE_SERVER=true
|
||||
- KEEP_JOB_DIR=false
|
||||
|
||||
Reference in New Issue
Block a user