提交 3534b039 作者: Knut Ahlers

Improve Dockerfile

* Added VOLUME to enable users to keep a state of the repo outside the container
* Added ipfs user to let ipfs run as a normal user and not as root
* Set IPFS_PATH to push IPFS to use the exposed dir
* Improved start script to be more verbose about errors
上级 83ca0154
FROM golang:1.4
MAINTAINER Brian Tiger Chow <btc@perfmode.com>
ENV IPFS_PATH /data/ipfs
RUN useradd -m -d /data -u 1000 ipfs && \
mkdir -p /data/ipfs && chown ipfs:ipfs /data/ipfs
EXPOSE 4001 5001 8080
# 4001 = Swarm, 5001 = API, 8080 = HTTP transport
VOLUME /data/ipfs
ADD . /go/src/github.com/ipfs/go-ipfs
RUN cd /go/src/github.com/ipfs/go-ipfs/cmd/ipfs && go install
RUN cp /go/src/github.com/ipfs/go-ipfs/bin/container_daemon /usr/local/bin/start_ipfs && \
chmod 755 /usr/local/bin/start_ipfs
EXPOSE 4001 5001 8080
# 4001 = Swarm, 5001 = API, 8080 = HTTP transport
USER ipfs
ENTRYPOINT ["/usr/local/bin/start_ipfs"]
......
#!/bin/bash
ipfs init
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
# Test whether the mounted directory is writable for us
if ( touch /data/ipfs/write_test 2>/dev/null ); then
rm /data/ipfs/write_test
else
echo "ERR: /data/ipfs is not writable for user 'ipfs' (UID 1000)"
exit 1
fi
echo "Running $(ipfs version)..."
if [ -e /data/ipfs/config ]; then
echo "Found ipfs repository. Not initializing."
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
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论