From 1c3670630682a330be460cc367509390c818712d Mon Sep 17 00:00:00 2001 From: Jesper Zedlitz Date: Thu, 8 Sep 2016 09:19:06 +0200 Subject: [PATCH] Changed Dockerfile so it uses a special entrypoint script. All parameters are passed through to weed. Depending on the command the entrypoint.sh script adds parameters to link containers. --- Dockerfile | 21 --------------------- docker/Dockerfile | 18 ++++++++++++++++++ docker/entrypoint.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 21 deletions(-) delete mode 100644 Dockerfile create mode 100644 docker/Dockerfile create mode 100755 docker/entrypoint.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e87538fdb..000000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM progrium/busybox - -WORKDIR /opt/weed - -RUN opkg-install curl -RUN echo tlsv1 >> ~/.curlrc - -RUN \ - curl -Lks https://bintray.com$(curl -Lk http://bintray.com/chrislusf/seaweedfs/seaweedfs/_latestVersion | grep linux_amd64.tar.gz | sed -n "/href/ s/.*href=['\"]\([^'\"]*\)['\"].*/\1/gp") | gunzip | tar -xf - -C /opt/weed/ && \ - mkdir ./bin && mv ./*/* ./bin && \ - chmod +x ./bin/weed - -EXPOSE 8080 -EXPOSE 9333 - -VOLUME /data - -ENV WEED_HOME /opt/weed -ENV PATH ${PATH}:${WEED_HOME}/bin - -ENTRYPOINT ["weed"] diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..ed1c4dfe3 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,18 @@ +FROM progrium/busybox + +COPY entrypoint.sh /entrypoint.sh +COPY Dockerfile /etc/Dockerfile + +RUN opkg-install curl +RUN echo tlsv1 >> ~/.curlrc + +RUN curl -Lks https://bintray.com$(curl -Lk http://bintray.com/chrislusf/seaweedfs/seaweedfs/_latestVersion | grep linux_amd64.tar.gz | sed -n "/href/ s/.*href=['\"]\([^'\"]*\)['\"].*/\1/gp") | gunzip | tar -xf - && \ + mv go_*amd64/weed /usr/bin/ && \ + rm -r go_*amd64 + +EXPOSE 8080 +EXPOSE 9333 + +VOLUME /data + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 000000000..bdde2caa4 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +case "$1" in + + 'master') + ARGS="-ip `hostname -i` -mdir /data" + # Is this instance linked with an other master? (Docker commandline "--link master1:master") + if [ -n "$MASTER_PORT_9333_TCP_ADDR" ] ; then + ARGS="$ARGS -peers=$MASTER_PORT_9333_TCP_ADDR:$MASTER_PORT_9333_TCP_PORT" + fi + /usr/bin/weed $@ $ARGS + ;; + + 'volume') + ARGS="-ip `hostname -i` -dir /data" + # Is this instance linked with a master? (Docker commandline "--link master1:master") + if [ -n "$MASTER_PORT_9333_TCP_ADDR" ] ; then + ARGS="$ARGS -mserver=$MASTER_PORT_9333_TCP_ADDR:$MASTER_PORT_9333_TCP_PORT" + fi + /usr/bin/weed $@ $ARGS + ;; + + 'server') + ARGS="-ip `hostname -i` -dir /data" + if [ -n "$MASTER_PORT_9333_TCP_ADDR" ] ; then + ARGS="$ARGS -master.peers=$MASTER_PORT_9333_TCP_ADDR:$MASTER_PORT_9333_TCP_PORT" + fi + /usr/bin/weed $@ $ARGS + ;; + + *) + /usr/bin/weed $@ + ;; +esac