From 83271214af221d34128886d0df2fbad9f8a02b62 Mon Sep 17 00:00:00 2001 From: SquidRings1 <146839825+SquidRings1@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:45:45 +0100 Subject: [PATCH] create a load-balancer --- docker-compose.yml | 17 ++++++++++++++++- traefik.toml | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 traefik.toml diff --git a/docker-compose.yml b/docker-compose.yml index d48fafb..6925f56 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,4 +3,19 @@ services: todolist: build : . # (1) ports: - - 8081:8080 # (2) + - 8080 # (2) + deploy: + replicas: 3 + labels: + - "traefik.http.routers.todolist.rule=PathPrefix(`/app`)" + - "traefik.http.middlewares.todolist.stripPrefix.prefixes=/app" + - "traefik.http.routers.todolist.middlewares=todolist@docker" + traefik: + image: traefik:2.5 + restart: unless-stopped + ports: + - 80:80 + - 8080:8080 + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ./traefik.toml:/traefik.toml diff --git a/traefik.toml b/traefik.toml new file mode 100644 index 0000000..c524277 --- /dev/null +++ b/traefik.toml @@ -0,0 +1,24 @@ +[global] +sendAnonymousUsage = false + +[accessLog] + +[log] +level = "DEBUG" +format = "common" + +[providers] +[providers.docker] +endpoint = "unix:///var/run/docker.sock" +watch = true +exposedByDefault = true +swarmMode = false + +[api] +dashboard = true +debug = false +insecure = true + +[entryPoints] +[entryPoints.insecure] +address = ":80"