diff --git a/Dockerfile b/Dockerfile index f9cac29..16b8780 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,12 @@ FROM alpine LABEL maintainer Bill Wang -RUN apk --update add git less openssh && \ - rm -rf /var/lib/apt/lists/* && \ - rm /var/cache/apk/* +COPY docker-entrypoint.sh /docker-entrypoint.sh + +RUN apk --update --no-cache add git less openssh-client VOLUME /git WORKDIR /git -ENTRYPOINT ["git"] +ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["--help"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..d8a51e1 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# A beginning user should be able to docker run image bash (or sh) without +# needing to learn about --entrypoint +# https://github.com/docker-library/official-images#consistency + +set -e + +# run command if it is not starting with a "-", is not a git subcommand and is an executable in PATH +if [ "${#}" -gt "0" ] && \ + [ "${1#-}" == "${1}" ] && \ + [ ! -x "/usr/libexec/git-core/git-${1}" ] && \ + command -v "${1}" > /dev/null 2>&1 ; then + exec "${@}" +else + # else default to run command with git + exec git "${@}" +fi