Skip to content

Commit

Permalink
Docker: improve for CRDTs
Browse files Browse the repository at this point in the history
This:

  * Allows choosing the consensus for the automatic "init" on Docker with
  IPFS_CLUSTER_CONSENSUS.

  * Removes IPFS_PATH and the sed replacements for 0.0.0.0 on RestAPI and
  Ipfsproxy endpoints because these are easily supported by setting env vars
  correctly and pose some security risk when running with net=host.

  * Brings up to date Dockerfile-test and Dockerfile-bundle, even if mostly
  unused.
  • Loading branch information
hsanjuan committed Aug 13, 2019
1 parent bd6d01b commit 4556cbe
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ MAINTAINER Hector Sanjuan <hector@protocol.ai>
ENV GOPATH /go
ENV SRC_PATH /go/src/github.com/ipfs/ipfs-cluster
ENV IPFS_CLUSTER_PATH /data/ipfs-cluster
ENV IPFS_CLUSTER_CONSENSUS crdt

EXPOSE 9094
EXPOSE 9095
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile-bundle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.9-stretch AS builder
FROM golang:1.12-stretch AS builder
MAINTAINER Hector Sanjuan <hector@protocol.ai>

# This dockerfile builds cluster and runs it along with go-ipfs.
Expand All @@ -22,6 +22,7 @@ MAINTAINER Hector Sanjuan <hector@protocol.ai>
ENV GOPATH /go
ENV SRC_PATH /go/src/github.com/ipfs/ipfs-cluster
ENV IPFS_CLUSTER_PATH /data/ipfs-cluster
ENV IPFS_CLUSTER_CONSENSUS crdt

EXPOSE 9094
EXPOSE 9095
Expand All @@ -38,4 +39,4 @@ VOLUME $IPFS_CLUSTER_PATH
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/start-daemons.sh"]

# Defaults for ipfs-cluster-service go here
CMD ["daemon", "--upgrade"]
CMD ["daemon"]
7 changes: 5 additions & 2 deletions Dockerfile-test
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ MAINTAINER Hector Sanjuan <hector@protocol.ai>
ENV GOPATH /go
ENV SRC_PATH /go/src/github.com/ipfs/ipfs-cluster
ENV IPFS_CLUSTER_PATH /data/ipfs-cluster
ENV IPFS_CLUSTER_CONSENSUS crdt
ENV IPFS_CLUSTER_RESTAPI_HTTPLISTENMULTIADDRESS /ip4/0.0.0.0/tcp/9094
ENV IPFS_CLUSTER_IPFSPROXY_LISTENMULTIADDRESS /ip4/0.0.0.0/tcp/9095

EXPOSE 9094
EXPOSE 9095
EXPOSE 9096

COPY --from=builder $GOPATH/bin/ipfs-cluster-service /usr/local/bin/ipfs-cluster-service
COPY --from=builder $GOPATH/bin/ipfs-cluster-ctl /usr/local/bin/ipfs-cluster-ctl
COPY --from=builder $SRC_PATH/docker/test-entrypoint.sh /usr/local/bin/start-daemons.sh
COPY --from=builder $SRC_PATH/docker/test-entrypoint.sh /usr/local/bin/test-entrypoint.sh
COPY --from=builder $SRC_PATH/docker/random-stopper.sh /usr/local/bin/random-stopper.sh
COPY --from=builder $SRC_PATH/docker/random-killer.sh /usr/local/bin/random-killer.sh
COPY --from=builder $SRC_PATH/docker/wait-killer-stopper.sh /usr/local/bin/wait-killer-stopper.sh
Expand All @@ -55,7 +58,7 @@ RUN mkdir -p $IPFS_CLUSTER_PATH && \
USER ipfs

VOLUME $IPFS_CLUSTER_PATH
ENTRYPOINT ["/usr/local/bin/start-daemons.sh"]
ENTRYPOINT ["/usr/local/bin/test-entrypoint.sh"]

# Defaults would go here
CMD ["daemon"]
12 changes: 2 additions & 10 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ if [ -e "${IPFS_CLUSTER_PATH}/service.json" ]; then
echo "Found IPFS cluster configuration at ${IPFS_CLUSTER_PATH}"
else
echo "This container only runs ipfs-cluster-service. ipfs needs to be run separately!"
echo "Initializing default configuration"
ipfs-cluster-service init
if [ -n "$IPFS_API" ]; then
echo "Using \$IPFS_API as value for ipfs_connector.ipfshttp.node_multiaddress in configuration"
sed -i "s;/ip4/127\.0\.0\.1/tcp/5001;$IPFS_API;" "${IPFS_CLUSTER_PATH}/service.json"
fi

echo "Warning: By default, the API and Proxy endpoints will listen on 0.0.0.0!"
sed -i 's;127\.0\.0\.1/tcp/9094;0.0.0.0/tcp/9094;' "${IPFS_CLUSTER_PATH}/service.json"
sed -i 's;127\.0\.0\.1/tcp/9095;0.0.0.0/tcp/9095;' "${IPFS_CLUSTER_PATH}/service.json"
echo "Initializing default configuration..."
ipfs-cluster-service init --consensus "${IPFS_CLUSTER_CONSENSUS}"
fi

exec ipfs-cluster-service $@
4 changes: 1 addition & 3 deletions docker/start-daemons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ ipfs-cluster-service --version
if [ -e "${IPFS_CLUSTER_PATH}/service.json" ]; then
echo "Found IPFS cluster configuration at ${IPFS_CLUSTER_PATH}"
else
ipfs-cluster-service init
sed -i 's/127\.0\.0\.1\/tcp\/9094/0.0.0.0\/tcp\/9094/' "${IPFS_CLUSTER_PATH}/service.json"
sed -i 's/127\.0\.0\.1\/tcp\/9095/0.0.0.0\/tcp\/9095/' "${IPFS_CLUSTER_PATH}/service.json"
ipfs-cluster-service init --consensus "${IPFS_CLUSTER_CONSENSUS}"
fi

exec ipfs-cluster-service $@
4 changes: 1 addition & 3 deletions docker/test-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ if [ -e "$IPFS_CLUSTER_PATH/service.json" ]; then
echo "Found IPFS cluster configuration at $IPFS_CLUSTER_PATH"
else
export CLUSTER_SECRET=""
ipfs-cluster-service init
sed -i 's/127\.0\.0\.1\/tcp\/9094/0.0.0.0\/tcp\/9094/' "$IPFS_CLUSTER_PATH/service.json"
sed -i 's/127\.0\.0\.1\/tcp\/9095/0.0.0.0\/tcp\/9095/' "$IPFS_CLUSTER_PATH/service.json"
ipfs-cluster-service init --consensus "${IPFS_CLUSTER_CONSENSUS}"
fi

ipfs-cluster-service --debug $@ &
Expand Down

0 comments on commit 4556cbe

Please # to comment.