From 1529bef0e60fa414e0730bf0a3369a34b6e4ebb8 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 19 Mar 2019 16:46:41 +0100 Subject: [PATCH] gomod: Update Dockerfile, remove Dockerfile.fast The main Dockerfile supports dependencies caching now, rendering Dockerfile.fast useless. License: MIT Signed-off-by: Jakub Sztandera --- Dockerfile | 17 +++++------ Dockerfile.fast | 75 ------------------------------------------------- 2 files changed, 7 insertions(+), 85 deletions(-) delete mode 100644 Dockerfile.fast diff --git a/Dockerfile b/Dockerfile index 405af0660625..17e3c1c90b30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,19 @@ -FROM golang:1.11-stretch +FROM golang:1.12-stretch MAINTAINER Lars Gierth -# There is a copy of this Dockerfile called Dockerfile.fast, -# which is optimized for build time, instead of image size. -# -# Please keep these two Dockerfiles in sync. +ENV SRC_DIR /go-ipfs -ENV GX_IPFS "" -ENV SRC_DIR /go/src/github.com/ipfs/go-ipfs +# Download packages first so they can be cached. +COPY go.mod go.sum $SRC_DIR/ +RUN cd $SRC_DIR \ + && go mod download COPY . $SRC_DIR # Build the thing. # Also: fix getting HEAD commit hash via git rev-parse. -# Also: allow using a custom IPFS API endpoint. RUN cd $SRC_DIR \ && mkdir .git/objects \ - && ([ -z "$GX_IPFS" ] || echo $GX_IPFS > /root/.ipfs/api) \ && make build # Get su-exec, a very minimal tool for dropping privileges, @@ -41,7 +38,7 @@ FROM busybox:1-glibc MAINTAINER Lars Gierth # Get the ipfs binary, entrypoint script, and TLS CAs from the build container. -ENV SRC_DIR /go/src/github.com/ipfs/go-ipfs +ENV SRC_DIR /go-ipfs COPY --from=0 $SRC_DIR/cmd/ipfs/ipfs /usr/local/bin/ipfs COPY --from=0 $SRC_DIR/bin/container_daemon /usr/local/bin/start_ipfs COPY --from=0 /tmp/su-exec/su-exec /sbin/su-exec diff --git a/Dockerfile.fast b/Dockerfile.fast deleted file mode 100644 index 0c03328eb211..000000000000 --- a/Dockerfile.fast +++ /dev/null @@ -1,75 +0,0 @@ -FROM golang:1.11-stretch -MAINTAINER Lars Gierth - -# This is a copy of /Dockerfile, -# except that we optimize for build time, instead of image size. -# -# Please keep these two Dockerfiles in sync. - -ENV GX_IPFS "" -ENV SRC_DIR /go/src/github.com/ipfs/go-ipfs - -COPY ./package.json $SRC_DIR/package.json - -# Fetch dependencies. -# Also: allow using a custom IPFS API endpoint. -RUN set -x \ - && go get github.com/whyrusleeping/gx \ - && go get github.com/whyrusleeping/gx-go \ - && ([ -z "$GX_IPFS" ] || echo $GX_IPFS > /root/.ipfs/api) \ - && cd $SRC_DIR \ - && gx install - -COPY . $SRC_DIR - -# Build the thing. -# Also: fix getting HEAD commit hash via git rev-parse. -RUN set -x \ - && cd $SRC_DIR \ - && mkdir .git/objects \ - && make build \ - && mv cmd/ipfs/ipfs /usr/local/bin/ipfs \ - && mv bin/container_daemon /usr/local/bin/start_ipfs - -# Get su-exec, a very minimal tool for dropping privileges, -# and tini, a very minimal init daemon for containers -ENV SUEXEC_VERSION v0.2 -ENV TINI_VERSION v0.16.1 -RUN set -x \ - && cd /tmp \ - && git clone https://github.com/ncopa/su-exec.git \ - && cd su-exec \ - && git checkout -q $SUEXEC_VERSION \ - && make \ - && cd /tmp \ - && wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini \ - && chmod +x tini \ - && mv su-exec/su-exec tini /sbin/ # Install them - -# Ports for Swarm TCP, Swarm uTP, API, Gateway, Swarm Websockets -EXPOSE 4001 -EXPOSE 4002/udp -EXPOSE 5001 -EXPOSE 8080 -EXPOSE 8081 - -# Create the fs-repo directory and switch to a non-privileged user. -ENV IPFS_PATH /data/ipfs -RUN mkdir -p $IPFS_PATH \ - && useradd -s /usr/sbin/nologin -d $IPFS_PATH -u 1000 -G users ipfs \ - && chown ipfs:users $IPFS_PATH - -# Expose the fs-repo as a volume. -# start_ipfs initializes an fs-repo if none is mounted. -VOLUME $IPFS_PATH - -# The default logging level -ENV IPFS_LOGGING "" - -# 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 ["/sbin/tini", "--", "/usr/local/bin/start_ipfs"] - -# Execute the daemon subcommand by default -CMD ["daemon", "--migrate=true"]