Closed troyswanson closed 7 years ago
Based on https://hub.docker.com/_/redis/
Dockerfile
FROM debian:jessie
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r disque && useradd -r -g disque disque
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# grab gosu for easy step-down from root
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN curl -o /usr/local/bin/gosu -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture)" \
&& curl -o /usr/local/bin/gosu.asc -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture).asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu
ENV DISQUE_VERSION 1.0-rc1
ENV DISQUE_DOWNLOAD_URL https://github.com/antirez/disque/archive/1.0-rc1.tar.gz
ENV DISQUE_DOWNLOAD_SHA1 b82a588a12994a14d5a2817b485be2f21808ad6a
RUN buildDeps='gcc libc6-dev make' \
&& set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /usr/src/disque \
&& curl -sSL "$DISQUE_DOWNLOAD_URL" -o disque.tar.gz \
&& echo "$DISQUE_DOWNLOAD_SHA1 *disque.tar.gz" | sha1sum -c - \
&& tar -xzf disque.tar.gz -C /usr/src/disque --strip-components=1 \
&& rm disque.tar.gz \
&& make -C /usr/src/disque \
&& make -C /usr/src/disque install \
&& rm -r /usr/src/disque \
&& apt-get purge -y --auto-remove $buildDeps
RUN mkdir /data && chown disque:disque /data
VOLUME /data
WORKDIR /data
COPY docker-entrypoint.sh /entrypoint.sh
COPY disque.conf /usr/local/etc/disque/disque.conf
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 7711 17711
CMD [ "disque-server", "/usr/local/etc/disque/disque.conf" ]
docker-entrypoint.sh
#!/bin/bash
set -e
if [ "$1" = 'disque-server' ]; then
chown -R disque .
exec gosu disque "$@"
fi
exec "$@"
Thanks @benbro. I've pushed a working Dockerfile on Docker Hub here if anyone is interested.
@antirez Would love any suggestions / improvements on the Dockerfile if you have any. I also am not completely sure about the best way to spin up > 1 node and getting them to meet in the docker world.
@swarajban Perhaps a Compose file? https://docs.docker.com/compose/compose-file/
@swarajban I'd go with a much smaller base image and not do the building in the docker image but rather assume the binary has already been built.
For example:
FROM base/archlinux:latest
ADD disque.conf /etc/disque/disque.conf
ADD src/disque-server /disque-server
ADD src/disque /disque
EXPOSE 7711
ENTRYPOINT [ "/disque-server", "/etc/disque/disque.conf" ]
Works quite nicely and is nice and small. Personally I'd prefer a Dockerfile for disque-server and one for the client. That way testing/use of the Disque CLI in a Docker setup doesn't need it locally installed. Gliderlabs did this quite well for Consul. For and example of how that works out so nicely see https://getcarina.com/docs/tutorials/data-stores-redis/ where it is the redis-client. Having a client-only Docker image would be quite nice. Failing that adding it into the server image would not be the end of the world.
Exposing the cluster bus port doesn't actually do any good here. More on that follows. As for spinning up multiple, Compose can do that part, but the assumption that the cluster bus port is base+10000 is broken by using standard docker networking. You can only do it if you're running in a docker cluster and use host networking. See issue #164 for details. As such until that is fixed a compose file will have to use the host networking option and thus only work when your docker setup points to a Docker Swarm.
Cheers, Bill
Thanks @therealbill. Agree with on all your points:
I'm currently using Kubernetes instead of compose & swarm, so I have related, but separate issues w.r.t. the cluster set up. Would definitely appreciate any advice / suggestions for recommended compose configurations
@swarajban I started working a docker-compose.yml file up. Until #164 is addressed (see Salvatore's latest comment on it) there are two cases - meaning two compose files.
Case 1: A docker swarm
In this case the compose file is fairly simple and straightforward. It can do everything but the closet meet
commands as that isn't something compose does. But I can get one here (or in a gist) which which sets up the containers at least.
Case 2: Single Docker host This is commonly the way developers and experimenters try it out. The catch here is having to use different ports for each host AND using host networking. Doable, but a tad more complex because you have to combine configuring disc with different ports and use host networking. Doable, but I'm not sure the same file can do either. I'll work on it this weekend to validate and past/gist one in. Or I suppose I could fork-and-PR. ;)
I either case Docker-Compose can't configure the cluster. I could write a tool which does it (and likely will) but that gets outside the context of a docker or compose file.
While this may be slightly off topic, I do have Disque clusters working in Vagrant if anyone is in need of a working dev cluster now: https://github.com/canardleteer/vagrant-disque
(@swarajban glad to hear that Alpine is getting some traction, I've been using it for years, and I'll probably convert the above to use Alpine instead of Ubuntu when I get a chance. It's an ideal slim distro.)
Would it make sense to include an official Dockerfile for this project?