Skip to content

Commit

Permalink
Rework Makefile & update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Grokzen committed Dec 25, 2014
1 parent 5c6c7df commit 8c55d96
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
48 changes: 24 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
CID_FILE = /tmp/grokzen-redis-cluster.cid
CID =`cat $(CID_FILE)`
IMAGE_NAME = grokzen/redis-cluster
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

help:
@echo "Please use 'make <target>' where <target> is one of"
@echo " docker-build build the docker image containing a redis cluster"
@echo " docker-rebuild rebuilds the image from scratch without using any cached layers"
@echo " docker-run run the built docker image"
@echo " docker-run-d run the built docker image"
@echo " docker-run-interactive run the built docker image"
@echo " docker-kill send stop signal to the running docker instance. do not remove image."
@echo " docker-remove remove the built docker image from you system"
@echo " dbuild build the docker image containing a redis cluster"
@echo " drebuild rebuilds the image from scratch without using any cached layers"
@echo " drun run the built docker image"
@echo " dbash starts bash inside a running container."
@echo " dclean removes the tmp cid file on disk"

docker-build:
dbuild:
@echo "Building docker image..."
docker build -t redis-server .
docker build -t ${IMAGE_NAME} .

docker-rebuild:
drebuild:
@echo "Rebuilding docker image..."
docker build --no-cache=true -t redis-server .
docker build --no-cache=true -t ${IMAGE_NAME} .

docker-run:
drun:
@echo "Running docker image..."
docker run -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -i -t redis-server

docker-run-d:
@echo "Running docker image in daemon mode..."
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
docker run -d $(PORTS) --cidfile $(CID_FILE) -i -t ${IMAGE_NAME}

docker-run-interactive:
@echo "Running docker image in interactive mode..."
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
dbash:
docker exec -it $(CID) /bin/bash

docker-kill:
@echo "NYI"
dstop:
docker stop $(CID)
-make dclean

docker-remove:
@echo "NYI"
dclean:
# Cleanup cidfile on disk
-rm $(CID_FILE)
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ Docker image with redis built and installed from source.

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

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

It will allways build the latest commit in the 3.0 branch `https://github.com/antirez/redis`



## Setup / Usage

How to setup docker and start the cluster image.

- 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.
- Run `make docker-build` or `make docker-rebuild` to build the image. When rebuilding the image, no cached layers will be used.
- Run one of

- `make docker-run` to start the server and tail first redis server (the one creating the cluster)
- `make docker-run-d` to run it in the background.
- `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]
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.

To build the image run either `make dbuild` or `make drebuild`. It will be built to the image name `grokzen/redis-cluster`.

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`.

- 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`
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 comments on commit 8c55d96

Please sign in to comment.