Skip to content

Commit 5ee2e65

Browse files
committed
Add second redis service
1 parent 341d5d7 commit 5ee2e65

5 files changed

+26
-3
lines changed

docker-compose.yml

+19-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ services:
33
image: redis
44
ports:
55
- 6379:6379
6+
labels:
7+
- com.packtpub.compose.app=task-manager
68
gorest:
7-
build: .
9+
build:
10+
context: .
11+
labels:
12+
- com.packtpub.compose.app=task-manager
813
image: task-manager:0.1
914
ports:
1015
- 8080:8080
@@ -17,4 +22,16 @@ services:
1722
retries: 5
1823
start_period: 5s
1924
depends_on:
20-
- redis
25+
- redis
26+
redis-populate:
27+
image: redis
28+
entrypoint: [ "/redis-populate.sh","/redis-populate.txt" ]
29+
depends_on:
30+
- redis
31+
env_file:
32+
- ./env.redis-populate
33+
volumes:
34+
- ./redis-populate.txt:/redis-populate.txt
35+
- ./redis-populate.sh:/redis-populate.sh
36+
labels:
37+
- com.packtpub.compose.app=task-manager

env.redis-populate

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HOST=redis
2+
PORT=6379

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func setupRouter() *gin.Engine {
3030

3131
// Health Check
3232
r.GET("/ping", func(c *gin.Context) {
33-
c.String(500, "pong")
33+
c.String(http.StatusOK, "pong")
3434
})
3535

3636
// Get tasks

redis-populate.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
cat $1| redis-cli -h $HOST -p $PORT

redis-populate.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HMSET task:a3a597d1-26f8-43e5-be05-81373f2c0dc3 Id a3a597d1-26f8-43e5-be05-81373f2c0dc3 Name "Existing Task" Description "A task that was here before" Timestamp 1645393434000
2+
ZADD tasks 1645393434000 "a3a597d1-26f8-43e5-be05-81373f2c0dc3"

0 commit comments

Comments
 (0)