diff --git a/.env.development.template b/.env.development.template index c897bff0e..3539bf1af 100644 --- a/.env.development.template +++ b/.env.development.template @@ -3,3 +3,4 @@ DATABASE_PORT=6432 DATABASE_NAME=spi_dev DATABASE_USERNAME=spi_dev DATABASE_PASSWORD=xxx +REDIS_HOST=localhost \ No newline at end of file diff --git a/.env.testing.template b/.env.testing.template index 1118c84ba..a2b58f4f5 100644 --- a/.env.testing.template +++ b/.env.testing.template @@ -3,3 +3,4 @@ DATABASE_PORT=5432 DATABASE_NAME=spi_test DATABASE_USERNAME=spi_test DATABASE_PASSWORD=xxx +REDIS_HOST=localhost \ No newline at end of file diff --git a/Makefile b/Makefile index 3ed081256..145e5a690 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,13 @@ ingest: analyze: swift run Run analyze --limit 1 -db-up: db-up-dev db-up-test +redis-up-dev: + docker run --name spi_redis -p 6379:6379 -d redis/redis-stack:7.4.0-v1 + +redis-down-dev: + docker rm -f spi_redis + +db-up: db-up-dev db-up-test redis-up-dev db-up-dev: docker run --name spi_dev -e POSTGRES_DB=spi_dev -e POSTGRES_USER=spi_dev -e POSTGRES_PASSWORD=xxx -p 6432:5432 -d postgres:16-alpine @@ -111,7 +117,7 @@ db-up-test: -d \ postgres:13-alpine -db-down: db-down-dev db-down-test +db-down: db-down-dev db-down-test redis-down-dev db-down-dev: docker rm -f spi_dev diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index e1846a1b9..05e3a00cf 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -80,7 +80,11 @@ public func configure(_ app: Application) async throws -> String { // Setup Redis connection do { - app.redis.configuration = try RedisConfiguration(hostname: "redis") + if let redisHost = Environment.get("REDIS_HOST") { + app.redis.configuration = try RedisConfiguration(hostname: redisHost) + } else { + app.logger.warning("REDIS_HOST not set, caching disabled.") + } } catch { app.logger.warning("Failed to configure Redis, caching disabled. Error: \(error)") } diff --git a/app.yml b/app.yml index 52d014365..335f7490b 100644 --- a/app.yml +++ b/app.yml @@ -63,6 +63,7 @@ x-shared: &shared TWITTER_API_SECRET: ${TWITTER_API_SECRET} TWITTER_ACCESS_TOKEN_KEY: ${TWITTER_ACCESS_TOKEN_KEY} TWITTER_ACCESS_TOKEN_SECRET: ${TWITTER_ACCESS_TOKEN_SECRET} + REDIS_HOST: ${REDIS_HOST} volumes: - checkouts:/checkouts