Skip to content

Commit

Permalink
Dockerfile: Deprecate implicit daemon argument
Browse files Browse the repository at this point in the history
After the discussion in ipfs#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 <git@rxv.cc>
  • Loading branch information
kpcyrd committed Feb 12, 2017
1 parent ac2d7a0 commit 77e4c64
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
1 change: 1 addition & 0 deletions Dockerfile.fast
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ RUN cd $SRC_PATH \
USER ipfs
VOLUME $IPFS_PATH
ENTRYPOINT ["/usr/local/bin/start_ipfs"]
CMD ["daemon"]
16 changes: 16 additions & 0 deletions bin/container_daemon
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"

0 comments on commit 77e4c64

Please sign in to comment.