-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
vendor libp2p with gx
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
.git | ||
.git/ | ||
!.git/HEAD | ||
!.git/refs/ | ||
cmd/ipfs/ipfs | ||
vendor/gx/ | ||
test/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,79 @@ | ||
FROM alpine:3.3 | ||
MAINTAINER Brian Tiger Chow <[email protected]> | ||
MAINTAINER Lars Gierth <[email protected]> | ||
|
||
# There is a copy of this Dockerfile in test/sharness, | ||
# which is optimized for build time, instead of image size. | ||
# | ||
# Please keep these two Dockerfiles in sync. | ||
|
||
ENV IPFS_PATH /data/ipfs | ||
ENV GOPATH /go:/go/src/github.com/ipfs/go-ipfs/Godeps/_workspace | ||
|
||
EXPOSE 4001 5001 8080 | ||
# 4001 = Swarm, 5001 = API, 8080 = HTTP transport | ||
# Ports for Swarm TCP, Swarm uTP, API, Gateway | ||
EXPOSE 4001 | ||
EXPOSE 4002/udp | ||
EXPOSE 5001 | ||
EXPOSE 8080 | ||
|
||
ADD bin/container_daemon /usr/local/bin/start_ipfs | ||
ADD bin/container_shacheck /usr/local/bin/shacheck | ||
# Volume for mounting an IPFS fs-repo | ||
# This is moved to the bottom for technical reasons. | ||
#VOLUME $IPFS_PATH | ||
|
||
ADD . /go/src/github.com/ipfs/go-ipfs | ||
WORKDIR /go/src/github.com/ipfs/go-ipfs/cmd/ipfs | ||
# IPFS API to use for fetching gx packages. | ||
# This can be a gateway too, since its read-only API provides all gx needs. | ||
# - e.g. /ip4/172.17.0.1/tcp/8080 if the Docker host | ||
# has the IPFS gateway listening on the bridge interface | ||
# provided by Docker's default networking. | ||
# - if empty, the public gateway at ipfs.io is used. | ||
ENV GX_IPFS "" | ||
# The IPFS fs-repo within the container | ||
ENV IPFS_PATH /data/ipfs | ||
# Golang stuff | ||
ENV GO_VERSION 1.5.3-r0 | ||
ENV GOPATH /go | ||
ENV PATH /go/bin:$PATH | ||
ENV SRC_PATH /go/src/github.com/ipfs/go-ipfs | ||
|
||
RUN adduser -D -h /data -u 1000 ipfs \ | ||
&& mkdir -p /data/ipfs && chown ipfs:ipfs /data/ipfs \ | ||
&& apk add --update bash ca-certificates git go \ | ||
&& go install -ldflags "-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$(git rev-parse --short HEAD 2> /dev/null || echo unknown)" \ | ||
&& mv /go/bin/ipfs /usr/local/bin/ipfs \ | ||
&& chmod 755 /usr/local/bin/start_ipfs \ | ||
&& apk del --purge go git | ||
# Get the go-ipfs sourcecode | ||
COPY . $SRC_PATH | ||
|
||
WORKDIR / | ||
RUN rm -rf /go/src/github.com/ipfs/go-ipfs | ||
RUN apk add --update musl go=$GO_VERSION git bash wget ca-certificates \ | ||
# Setup user and fs-repo directory | ||
&& mkdir -p $IPFS_PATH \ | ||
&& adduser -D -h $IPFS_PATH -u 1000 ipfs \ | ||
&& chown ipfs:ipfs $IPFS_PATH && chmod 755 $IPFS_PATH \ | ||
# Install gx | ||
&& go get -u github.com/whyrusleeping/gx \ | ||
&& go get -u github.com/whyrusleeping/gx-go \ | ||
# Point gx to a specific IPFS API | ||
&& ([ -z "$GX_IPFS" ] || echo $GX_IPFS > $IPFS_PATH/api) \ | ||
# Invoke gx | ||
&& cd $SRC_PATH \ | ||
&& gx --verbose install --global \ | ||
# We get the current commit using this hack, | ||
# so that we don't have to copy all of .git/ into the build context. | ||
# This saves us quite a bit of image size. | ||
&& ref="$(cat .git/HEAD | cut -d' ' -f2)" \ | ||
&& commit="$(cat .git/$ref | head -c 7)" \ | ||
&& echo "ldflags=-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$commit" \ | ||
# Build and install IPFS and entrypoint script | ||
&& cd $SRC_PATH/cmd/ipfs \ | ||
&& go build -ldflags "-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$commit" \ | ||
&& cp ipfs /usr/local/bin/ipfs \ | ||
&& cp $SRC_PATH/bin/container_daemon /usr/local/bin/start_ipfs \ | ||
&& chmod 755 /usr/local/bin/start_ipfs \ | ||
# Remove all build-time dependencies | ||
&& apk del --purge musl go git && rm -rf $GOPATH && rm -vf $IPFS_PATH/api | ||
|
||
# Call uid 1000 "ipfs" | ||
USER ipfs | ||
VOLUME /data/ipfs | ||
|
||
ENTRYPOINT ["/usr/local/bin/start_ipfs"] | ||
# Expose the fs-repo as a volume. | ||
# We're doing this down here (and not at the top), | ||
# so that the overlay directory is owned by the ipfs user. | ||
# start_ipfs initializes an ephemeral fs-repo if none is mounted, | ||
# which is why uid=1000 needs write permissions there. | ||
VOLUME $IPFS_PATH | ||
|
||
# build: docker build -t go-ipfs . | ||
# run: docker run -p 4001:4001 -p 5001:5001 go-ipfs:latest | ||
# run: docker run -p 8080:8080 -p 4001:4001 -p 5001:5001 go-ipfs:latest | ||
# This just makes sure that: | ||
# 1. There's an fs-repo, and initializes one if there isn't. | ||
# 2. The API and Gateway are accessible from outside the container. | ||
ENTRYPOINT ["/usr/local/bin/start_ipfs"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.