Docker test image build (#103)
* First draft of test dockerfile build * Test dockerfile, build works, container runs and cluster tests go through * Removed fifo for output * renaming dockerfile
This commit is contained in:
parent
7943a7fb6c
commit
0c9f729662
34
Dockerfile-test
Normal file
34
Dockerfile-test
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
FROM ipfs/go-ipfs:release
|
||||||
|
MAINTAINER Hector Sanjuan <hector@protocol.ai>
|
||||||
|
|
||||||
|
EXPOSE 9094
|
||||||
|
EXPOSE 9095
|
||||||
|
EXPOSE 9096
|
||||||
|
|
||||||
|
ENV GOPATH /go
|
||||||
|
ENV PATH /go/bin:$PATH
|
||||||
|
ENV SRC_PATH /go/src/github.com/ipfs/ipfs-cluster
|
||||||
|
ENV IPFS_CLUSTER_PATH /data/ipfs-cluster
|
||||||
|
|
||||||
|
VOLUME $IPFS_CLUSTER_PATH
|
||||||
|
|
||||||
|
COPY . $SRC_PATH
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual cluster-deps make musl-dev go git \
|
||||||
|
&& apk add --no-cache jq \
|
||||||
|
&& go get -u github.com/whyrusleeping/gx \
|
||||||
|
&& go get -u github.com/whyrusleeping/gx-go \
|
||||||
|
&& cd $SRC_PATH \
|
||||||
|
&& gx install --global \
|
||||||
|
&& gx-go rewrite \
|
||||||
|
&& go build \
|
||||||
|
&& make -C ipfs-cluster-service install \
|
||||||
|
&& make -C ipfs-cluster-ctl install \
|
||||||
|
&& cp docker/test-entrypoint.sh /usr/local/bin/start-daemons.sh \
|
||||||
|
&& chmod +x /usr/local/bin/start-daemons.sh \
|
||||||
|
&& apk del --purge cluster-deps \
|
||||||
|
&& cd / && rm -rf /go/src /go/bin/gx /go/bin/gx-go
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/start-daemons.sh"]
|
||||||
|
|
||||||
|
CMD ["$IPFS_CLUSTER_OPTS"]
|
50
docker/test-entrypoint.sh
Normal file
50
docker/test-entrypoint.sh
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
user=ipfs
|
||||||
|
repo="$IPFS_PATH"
|
||||||
|
echo "Version 0.4"
|
||||||
|
|
||||||
|
if [ `id -u` -eq 0 ]; then
|
||||||
|
# ensure folders are writeable
|
||||||
|
su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo"
|
||||||
|
su-exec "$user" test -w "$IPFS_CLUSTER_PATH" || chown -R -- "$user" "$IPFS_CLUSTER_PATH"
|
||||||
|
# restart script with new privileges
|
||||||
|
exec su-exec "$user" "$0" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Second invocation with regular user
|
||||||
|
echo "Second invocation"
|
||||||
|
|
||||||
|
if [ `id -u` -eq 0 ]; then
|
||||||
|
# ensure directories are writable
|
||||||
|
su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo"
|
||||||
|
su-exec "$user" test -w "$IPFS_CLUSTER_PATH" || chown -R -- "$user" "$IPFS_CLUSTER_PATH"
|
||||||
|
exec su-exec "$user" "$0" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipfs version
|
||||||
|
|
||||||
|
if [ -e "$repo/config" ]; then
|
||||||
|
echo "Found IPFS fs-repo at $repo"
|
||||||
|
else
|
||||||
|
ipfs init
|
||||||
|
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
|
||||||
|
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipfs daemon --migrate=true &
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
ipfs-cluster-service $@ &
|
||||||
|
echo "Daemons launched"
|
||||||
|
exec tail -f /dev/null
|
Loading…
Reference in New Issue
Block a user