fix(backend): don't hardcode redis URL, add redis to docker compose

This commit is contained in:
sam 2025-03-04 17:25:07 +01:00
parent 7759225428
commit f99d10ecf0
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
2 changed files with 10 additions and 3 deletions

View file

@ -24,8 +24,7 @@ namespace Foxnouns.Backend.Services;
public class KeyCacheService(Config config) public class KeyCacheService(Config config)
{ {
public ConnectionMultiplexer Multiplexer { get; } = public ConnectionMultiplexer Multiplexer { get; } =
// ConnectionMultiplexer.Connect(config.Database.Redis); ConnectionMultiplexer.Connect(config.Database.Redis);
ConnectionMultiplexer.Connect("127.0.0.1:6379");
public async Task SetKeyAsync(string key, string value, Duration expireAfter) => public async Task SetKeyAsync(string key, string value, Duration expireAfter) =>
await Multiplexer await Multiplexer

View file

@ -7,6 +7,7 @@ services:
environment: environment:
- "Database:Url=Host=postgres;Database=postgres;Username=postgres;Password=postgres" - "Database:Url=Host=postgres;Database=postgres;Username=postgres;Password=postgres"
- "Database:EnablePooling=true" - "Database:EnablePooling=true"
- "Database:Redis=redis:6379"
- "Host=0.0.0.0" - "Host=0.0.0.0"
- "Port=5000" - "Port=5000"
- "Logging:MetricsPort=5001" - "Logging:MetricsPort=5001"
@ -31,7 +32,7 @@ services:
rate: rate:
image: rate image: rate
build: ./rate build: ./Foxnouns.RateLimiter
environment: environment:
- "PORT=5003" - "PORT=5003"
restart: unless-stopped restart: unless-stopped
@ -52,6 +53,12 @@ services:
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
redis:
image: registry.redict.io/redict:7
restart: unless-stopped
volumes:
- redict_data:/data
caddy: caddy:
image: docker.io/caddy:2 image: docker.io/caddy:2
restart: unless-stopped restart: unless-stopped
@ -67,3 +74,4 @@ volumes:
caddy_data: caddy_data:
caddy_config: caddy_config:
postgres_data: postgres_data:
redict_data: