Skip to content

Commit

Permalink
Merge pull request #384 from stakwork/fix/add-traefik-aws-region
Browse files Browse the repository at this point in the history
fix: traefik aws region
  • Loading branch information
Evanfeenstra authored Nov 6, 2024
2 parents f8e0226 + 6b0c22a commit c9e587d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
4 changes: 3 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "2"

services:
reverse-proxy:
image: traefik:v2.2.1
image: traefik:v2.9
container_name: traefik.sphinx
restart: unless-stopped
networks:
Expand Down Expand Up @@ -34,6 +34,8 @@ services:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/admin/letsencrypt:/letsencrypt
environment:
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
load_balancer:
image: traefik:v2.2.1
image: traefik:v2.9
container_name: load_balancer
restart: unless-stopped
networks:
Expand Down Expand Up @@ -32,6 +32,8 @@ services:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/admin/letsencrypt:/letsencrypt
environment:
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
Expand Down
4 changes: 3 additions & 1 deletion second-brain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "2"

services:
load_balancer:
image: traefik:v2.2.1
image: traefik:v2.9
container_name: load_balancer
restart: unless-stopped
networks:
Expand Down Expand Up @@ -36,6 +36,8 @@ services:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/admin/letsencrypt:/letsencrypt
environment:
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
Expand Down
4 changes: 3 additions & 1 deletion sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "2"

services:
reverse-proxy:
image: traefik:v2.2.1
image: traefik:v2.9
container_name: traefik.sphinx
restart: unless-stopped
networks:
Expand Down Expand Up @@ -36,6 +36,8 @@ services:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/admin/letsencrypt:/letsencrypt
environment:
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
Expand Down
4 changes: 3 additions & 1 deletion sphinxv2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "2"

services:
reverse-proxy:
image: traefik:v2.2.1
image: traefik:v2.9
container_name: traefik.sphinx
restart: unless-stopped
networks:
Expand Down Expand Up @@ -36,6 +36,8 @@ services:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/admin/letsencrypt:/letsencrypt
environment:
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
Expand Down
18 changes: 16 additions & 2 deletions src/images/traefik.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ ulimits:
hard: 1000000
*/

fn _aws_env() -> Option<Vec<String>> {
let aws_region = std::env::var("AWS_REGION");
if let Err(_) = aws_region {
return None;
}
Some(vec![format!("AWS_REGION={}", aws_region.unwrap())])
}

fn _traefik(img: &TraefikImage) -> Config<String> {
let name = img.name.clone();
let image = "traefik:v2.2.1";
let image = "traefik:v2.9";
let mut ports = vec!["80", "443"];
let insecure = match std::env::var("TRAEFIK_INSECURE") {
Ok(_) => true,
Expand Down Expand Up @@ -87,6 +95,12 @@ fn _traefik(img: &TraefikImage) -> Config<String> {
}
let add_ulimits = true;
let add_log_limit = true;
let awsenv = _aws_env();
if let Some(ae) = &awsenv {
log::info!("traefik: using AWS REGION env {:?}", ae.get(0));
} else {
log::error!("traefik: MISSING AWS REGION ENV!");
}

log::error!("traefik: MISSING AWS ENV!");

Expand All @@ -99,7 +113,7 @@ fn _traefik(img: &TraefikImage) -> Config<String> {
add_ulimits,
add_log_limit,
),
env: None,
env: awsenv,
cmd: Some(strarr(cmd)),
..Default::default()
}
Expand Down
4 changes: 3 additions & 1 deletion superadmin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "2"

services:
load_balancer:
image: traefik:v2.2.1
image: traefik:v2.9
container_name: load_balancer
restart: unless-stopped
networks:
Expand Down Expand Up @@ -34,6 +34,8 @@ services:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/admin/letsencrypt:/letsencrypt
environment:
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
Expand Down

0 comments on commit c9e587d

Please sign in to comment.