From 8840c6b9c7a0dd5f2a12c652782190ac73e90743 Mon Sep 17 00:00:00 2001 From: Erin Power Date: Sun, 10 Apr 2022 15:04:11 +0200 Subject: [PATCH] add compose --- Earthfile | 10 ++++++++++ compose.yml | 27 +++++++++++++++++++++++++++ nginx.conf | 24 ++++++++++++++++++++++++ src/main.rs | 1 + 4 files changed, 62 insertions(+) create mode 100644 compose.yml create mode 100644 nginx.conf diff --git a/Earthfile b/Earthfile index 913ed47..520ef0f 100644 --- a/Earthfile +++ b/Earthfile @@ -40,3 +40,13 @@ docker: COPY +build/tokei_rs tokei_rs ENTRYPOINT ["./tokei_rs"] SAVE IMAGE --push ghcr.io/xampprocky/tokei_rs + +compose: + FROM earthly/dind:alpine + WORKDIR /test + COPY compose.yml ./ + WITH DOCKER \ + --compose compose.yml \ + --load ghcr.io/xampprocky/tokei_rs:latest=(+docker) + RUN docker compose down && docker compose up --remove-orphans + END diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..bcfd266 --- /dev/null +++ b/compose.yml @@ -0,0 +1,27 @@ +version: "3.7" + +networks: + web: + external: true + internal: + external: false + driver: bridge + +services: + nginx: + image: nginx:alpine + restart: unless-stopped + ports: + - "80:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + networks: + - web + - internal + + badge: + image: ghcr.io/xampprocky/tokei_rs + environment: + - RUST_LOG=debug + networks: + - internal diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f96a3ec --- /dev/null +++ b/nginx.conf @@ -0,0 +1,24 @@ +events { worker_connections 1024; } + +http { + + upstream app_servers { # Create an upstream for the web servers + server badge:8000; # the first server + } + + server { + listen 80; + + location / { + proxy_pass http://app_servers; # load balance the traffic + } + } + + server { + listen 443; + + location / { + proxy_pass http://app_servers; # load balance the traffic + } + } +} diff --git a/src/main.rs b/src/main.rs index 035a613..823e902 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,6 +122,7 @@ async fn create_badge( .ok_or_else(|| actix_web::error::ErrorBadRequest(eyre::eyre!("Invalid SHA provided.")))?; if let Ok(if_none_match) = IfNoneMatch::parse(&request) { + log::debug!("Checking If-None-Match: {}", sha); let sha_tag = EntityTag::new(false, sha.clone()); let found_match = match if_none_match { IfNoneMatch::Any => false,