Skip to content

Commit 8c55d96

Browse files
committed
Rework Makefile & update Readme
1 parent 5c6c7df commit 8c55d96

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

Makefile

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1+
CID_FILE = /tmp/grokzen-redis-cluster.cid
2+
CID =`cat $(CID_FILE)`
3+
IMAGE_NAME = grokzen/redis-cluster
4+
PORTS = -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -p 7006:7006 -p 7007:7007
5+
16
help:
27
@echo "Please use 'make <target>' where <target> is one of"
3-
@echo " docker-build build the docker image containing a redis cluster"
4-
@echo " docker-rebuild rebuilds the image from scratch without using any cached layers"
5-
@echo " docker-run run the built docker image"
6-
@echo " docker-run-d run the built docker image"
7-
@echo " docker-run-interactive run the built docker image"
8-
@echo " docker-kill send stop signal to the running docker instance. do not remove image."
9-
@echo " docker-remove remove the built docker image from you system"
8+
@echo " dbuild build the docker image containing a redis cluster"
9+
@echo " drebuild rebuilds the image from scratch without using any cached layers"
10+
@echo " drun run the built docker image"
11+
@echo " dbash starts bash inside a running container."
12+
@echo " dclean removes the tmp cid file on disk"
1013

11-
docker-build:
14+
dbuild:
1215
@echo "Building docker image..."
13-
docker build -t redis-server .
16+
docker build -t ${IMAGE_NAME} .
1417

15-
docker-rebuild:
18+
drebuild:
1619
@echo "Rebuilding docker image..."
17-
docker build --no-cache=true -t redis-server .
20+
docker build --no-cache=true -t ${IMAGE_NAME} .
1821

19-
docker-run:
22+
drun:
2023
@echo "Running docker image..."
21-
docker run -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -i -t redis-server
22-
23-
docker-run-d:
24-
@echo "Running docker image in daemon mode..."
25-
docker run -d -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -i -t redis-server
24+
docker run -d $(PORTS) --cidfile $(CID_FILE) -i -t ${IMAGE_NAME}
2625

27-
docker-run-interactive:
28-
@echo "Running docker image in interactive mode..."
29-
docker run -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -i -t redis-server /sbin/my_init --enable-insecure-key -- /bin/bash
26+
dbash:
27+
docker exec -it $(CID) /bin/bash
3028

31-
docker-kill:
32-
@echo "NYI"
29+
dstop:
30+
docker stop $(CID)
31+
-make dclean
3332

34-
docker-remove:
35-
@echo "NYI"
33+
dclean:
34+
# Cleanup cidfile on disk
35+
-rm $(CID_FILE)

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ Docker image with redis built and installed from source.
44

55
The cluster is 6 redis instances running with 3 master & 3 slaves, one slave for each master. They run on ports 7000 to 7005.
66

7-
It will allways build the latest commit in the 3.0 branch from redis repo `https://github.com/antirez/redis`.
7+
It also contains 2 standalone instances that is not part of the cluster. They are running on port 7006 & 7007
8+
9+
It will allways build the latest commit in the 3.0 branch `https://github.com/antirez/redis`
810

911

1012

1113
## Setup / Usage
1214

1315
How to setup docker and start the cluster image.
1416

15-
- Install `docker` on your system. 1.0 or higher is recommended. Instructions can be found at http://docs.docker.com/en/latest/installation/. It is also reccomended to add the current user to `docker` system group to remove the need to add sudo to each docker call.
16-
- Run `make docker-build` or `make docker-rebuild` to build the image. When rebuilding the image, no cached layers will be used.
17-
- Run one of
18-
19-
- `make docker-run` to start the server and tail first redis server (the one creating the cluster)
20-
- `make docker-run-d` to run it in the background.
21-
- `make docker-run-interactive` starts `/bin/bash` (good for debugging) [`start.sh` have to be runned manually. No cluster will be created, Supervisord will not start automatically]
17+
Install `docker` on your system. 1.0 or higher is recommended. Instructions can be found at http://docs.docker.com/en/latest/installation/. It is also reccomended to add the current user to `docker` system group to remove the need to add sudo to each docker call.
18+
19+
To build the image run either `make dbuild` or `make drebuild`. It will be built to the image name `grokzen/redis-cluster`.
20+
21+
To start the image run `make drun`. It will be started in the background. To gain access to the running image you can get a bash session by running `make dbash`.
2222

23-
- Test to connect to the cluster with `redis-cli -p 7000`. If you do not want to install a redis server on your host to get access to `redis-cli` you can run a `exec` command to run it inside the docker container. It can be done with `docker exec -it <ContainerID> /redis/src/redis-cli -p 7000` where `<ContainerID>` can be found via `docker ps`
23+
Test to connect to the cluster with `redis-cli -p 7000`. If you do not want to install a redis server on your host to get access to `redis-cli` you can run a `exec` command to run it inside the docker container. It can be done with `docker exec -it <ContainerID> /redis/src/redis-cli -p 7000` where `<ContainerID>` can be found inside the CID file at `/tmp/grokzen-redis-cluster.cid` or via `docker ps`.

0 commit comments

Comments
 (0)