Skip to content

Dockerfile does not conform to entrypoint best practice #8 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo: required

services:
- docker

script: make
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ FROM alpine

LABEL maintainer Bill Wang <[email protected]>

RUN apk --update add git openssh && \
RUN apk --update add git openssh bash && \
rm -rf /var/lib/apt/lists/* && \
rm /var/cache/apk/*

COPY docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh

VOLUME /git
WORKDIR /git

ENTRYPOINT ["git"]
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
CMD ["--help"]
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
RELEASE_TYPE ?= patch
SEMVER_IMAGE ?= alpine/semver

CURRENT_VERSION := $(shell git tag -l -n [0-9]* | sort --version-sort -r | awk 'NR==1{print $$1}' )

ifndef CURRENT_VERSION
CURRENT_VERSION := 0.0.0
endif

NEXT_VERSION := $(shell docker run --rm $(SEMVER_IMAGE) semver -c -i $(RELEASE_TYPE) $(CURRENT_VERSION))

BRANCH = $(shell git rev-parse --abbrev-ref HEAD)

.PHONY: all current-version next-version release
all: release

current-version:
@echo $(CURRENT_VERSION)

next-version:
@echo $(NEXT_VERSION)

release:
if [ "$(BRANCH)" = "master" ];then \
git tag $(NEXT_VERSION) ;\
git push --tags ;\
fi
15 changes: 15 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/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

# allow to run "sh" or "bash"
if [ "$1" = 'sh' ] || [ "$1" = 'bash' ]; then
exec "$@"
else
# else default to run command with git
exec git "$@"
fi