From 77e4c64ac02e01afbbd92e516371f3a742d766d4 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Sun, 12 Feb 2017 20:44:05 +0000 Subject: [PATCH 1/3] Dockerfile: Deprecate implicit daemon argument After the discussion in https://github.com/ipfs/go-ipfs/pull/3573 this patch prints a deprecation warning if: 1) the image has been executed with additional arguments 2) the first argument isn't daemon This way people are able to migrate to the new syntax without any breaking changes. License: MIT Signed-off-by: kpcyrd --- Dockerfile | 3 +++ Dockerfile.fast | 1 + bin/container_daemon | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7efa81ea7..20b54b602 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,3 +74,6 @@ VOLUME $IPFS_PATH # 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"] + +# Execute the daemon subcommand by default +CMD ["daemon"] diff --git a/Dockerfile.fast b/Dockerfile.fast index 0993920b3..24bec6d6b 100644 --- a/Dockerfile.fast +++ b/Dockerfile.fast @@ -53,3 +53,4 @@ RUN cd $SRC_PATH \ USER ipfs VOLUME $IPFS_PATH ENTRYPOINT ["/usr/local/bin/start_ipfs"] +CMD ["daemon"] diff --git a/bin/container_daemon b/bin/container_daemon index fd939338f..bb6d8ccd1 100644 --- a/bin/container_daemon +++ b/bin/container_daemon @@ -19,4 +19,20 @@ else ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 fi +# if the first argument is daemon +if [ "$1" = "daemon" ]; then + # filter the first argument until + # https://github.com/ipfs/go-ipfs/pull/3573 + # has been resolved + shift +else + # print deprecation warning + # go-ipfs used to hardcode "ipfs daemon" in it's entrypoint + # this workaround supports the new syntax so people start setting daemon explicitly + # when overwriting CMD, making this PR safe to merge + echo "DEPRECATED: arguments have been set but the first argument isn't 'daemon'" >&2 + echo "DEPRECATED: run 'docker run ipfs/go-ipfs daemon $@' instead" >&2 + echo "DEPRECATED: see https://github.com/ipfs/go-ipfs/pull/3573 for more information" >&2 +fi + exec ipfs daemon "$@" From 04c95fa9d0db4955dfa681ff3f52fec87436e056 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Sun, 12 Feb 2017 20:58:25 +0000 Subject: [PATCH 2/3] Mention the new PR as well License: MIT Signed-off-by: kpcyrd --- bin/container_daemon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/container_daemon b/bin/container_daemon index bb6d8ccd1..8cf8ec422 100644 --- a/bin/container_daemon +++ b/bin/container_daemon @@ -32,7 +32,9 @@ else # when overwriting CMD, making this PR safe to merge echo "DEPRECATED: arguments have been set but the first argument isn't 'daemon'" >&2 echo "DEPRECATED: run 'docker run ipfs/go-ipfs daemon $@' instead" >&2 - echo "DEPRECATED: see https://github.com/ipfs/go-ipfs/pull/3573 for more information" >&2 + echo "DEPRECATED: see the following PRs for more information:" >&2 + echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3573" >&2 + echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3685" >&2 fi exec ipfs daemon "$@" From 3799bcfc2e385009bce34ee2269d6261a0ca6720 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Sun, 12 Feb 2017 21:10:28 +0000 Subject: [PATCH 3/3] Docker: Automatically migrate repo This keeps docker containers from entering a crashloop on new image versions License: MIT Signed-off-by: kpcyrd --- Dockerfile | 2 +- Dockerfile.fast | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20b54b602..42c4561d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,4 +76,4 @@ VOLUME $IPFS_PATH ENTRYPOINT ["/usr/local/bin/start_ipfs"] # Execute the daemon subcommand by default -CMD ["daemon"] +CMD ["daemon", "--migrate=true"] diff --git a/Dockerfile.fast b/Dockerfile.fast index 24bec6d6b..b10568ad6 100644 --- a/Dockerfile.fast +++ b/Dockerfile.fast @@ -53,4 +53,4 @@ RUN cd $SRC_PATH \ USER ipfs VOLUME $IPFS_PATH ENTRYPOINT ["/usr/local/bin/start_ipfs"] -CMD ["daemon"] +CMD ["daemon", "--migrate=true"]