diff --git a/README.md b/README.md index 7134673..76abe89 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ A collection of delicious docker recipes. - [x] taskd - [x] tftpd - [x] tmail :beetle: +- [x] twemproxy - [x] vsftpd - [x] webhook - [x] webkit :beetle: diff --git a/twemproxy/Dockerfile b/twemproxy/Dockerfile new file mode 100644 index 0000000..29a2e39 --- /dev/null +++ b/twemproxy/Dockerfile @@ -0,0 +1,29 @@ +# +# Dockerfile for twemproxy +# + +FROM alpine:3 + +ENV TWEMPROXY_VERSION=0.4.1 +ENV TWEMPROXY_URL=https://github.com/twitter/twemproxy/archive/v${TWEMPROXY_VERSION}.tar.gz +ENV TWEMPROXY_HOME=/opt/twemproxy + +WORKDIR ${TWEMPROXY_HOME} + +RUN set -xe \ + && apk --no-cache add -t TMP alpine-sdk autoconf automake curl libtool tar \ + && mkdir -p conf logs src \ + && curl -sSL ${TWEMPROXY_URL} | tar xz --strip 1 -C src \ + && cd src \ + && autoreconf -fvi \ + && CFLAGS="-O3" ./configure \ + && make install \ + && nutcracker --version \ + && cd .. \ + && rm -rf src \ + && apk del TMP + +EXPOSE 22222 + +ENTRYPOINT ["nutcracker"] +CMD ["--help"] diff --git a/twemproxy/README.md b/twemproxy/README.md new file mode 100644 index 0000000..659087f --- /dev/null +++ b/twemproxy/README.md @@ -0,0 +1,28 @@ +twemproxy +========= + +[twemproxy][1] (pronounced "two-em-proxy"), aka nutcracker is a fast and +lightweight proxy for memcached and redis protocol. It was built primarily to +reduce the number of connections to the caching servers on the backend. This, +together with protocol pipelining and sharding enables you to horizontally +scale your distributed caching architecture. + +## up and running + +```bash +$ docker-compose up -d + +$ docker-compose exec redis redis-cli -h twemproxy +twemproxy:6379> ping +PONG +twemproxy:6379> set hello world +OK +twemproxy:6379> get hello +"world" +twemproxy:6379> del hello +(integer) 1 + +$ tail -f data/twemproxy/logs/nutcracker.log +``` + +[1]: https://github.com/twitter/twemproxy diff --git a/twemproxy/data/redis/.gitkeep b/twemproxy/data/redis/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/twemproxy/data/twemproxy/conf/nutcracker.yml b/twemproxy/data/twemproxy/conf/nutcracker.yml new file mode 100644 index 0000000..8b5edab --- /dev/null +++ b/twemproxy/data/twemproxy/conf/nutcracker.yml @@ -0,0 +1,10 @@ +alpha: + listen: 0.0.0.0:6379 + hash: fnv1a_64 + distribution: ketama + auto_eject_hosts: true + redis: true + server_retry_timeout: 2000 + server_failure_limit: 1 + servers: + - redis:6379:1 diff --git a/twemproxy/data/twemproxy/logs/nutcracker.log b/twemproxy/data/twemproxy/logs/nutcracker.log new file mode 100644 index 0000000..e69de29 diff --git a/twemproxy/docker-compose.yml b/twemproxy/docker-compose.yml new file mode 100644 index 0000000..f3cae44 --- /dev/null +++ b/twemproxy/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3.7" + +services: + + twemproxy: + image: vimagick/twemproxy + command: > + --conf-file=conf/nutcracker.yml + --output=logs/nutcracker.log + --verbose=5 + ports: + - "6379:6379" + - "22222:22222" + volumes: + - ./data/twemproxy:/opt/twemproxy + depends_on: + - redis + restart: unless-stopped + + redis: + image: redis:alpine + volumes: + - ./data/redis:/data + restart: unless-stopped