Skip to content

Commit

Permalink
add spring profiles to change the redis host depending on whether the…
Browse files Browse the repository at this point in the history
… application runs in docker or locally.
  • Loading branch information
cookieID committed Nov 25, 2024
1 parent d87aa94 commit 135cfab
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ on:
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
name: Maven Build
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
redis:
image: redis:7.4.0-alpine
image: redis:7.4.0
container_name: redis
restart: always
ports:
Expand Down Expand Up @@ -36,8 +36,7 @@ services:
depends_on:
- redis
environment:
SPRING_DATA_REDIS_HOST: redis
SPRING_DATA_REDIS_PORT: 6379
- SPRING_PROFILES_ACTIVE=docker # select active profile in spring
networks:
- app-network

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application-docker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redis configuration for Docker
spring.data.redis.host=redis
2 changes: 2 additions & 0 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redis configuration for local deployment
spring.data.redis.host=127.0.0.1
6 changes: 4 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

# Redis Database
# for local deplyoment change redis.host to 127.0.0.1 (when the application runs inside docker redis.host neds to be redis)
spring.data.redis.host=redis
#spring.data.redis.host=redis
# Default profile (common settings)
spring.data.redis.host=127.0.0.1
spring.data.redis.port=6379
spring.data.redis.username=
spring.data.redis.password=
Expand All @@ -21,4 +23,4 @@ management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=health

# Define timeout setting for TLR services (in seconds)
tlr.timeout.seconds=60
tlr.timeout.seconds=60

0 comments on commit 135cfab

Please sign in to comment.