diff --git a/Dockerfile b/Dockerfile index 4ee7c5c..e376c33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,26 @@ -FROM golang:1.14.2-alpine3.11 AS buildenv +ARG GOVERSION="1.14.2" + +FROM golang:${GOVERSION}-alpine AS buildenv + +ARG REPO="https://gitea.com/gitea/tea.git" ARG VERSION="0.3.0" ENV TEA_VERSION="${VERSION}" + ARG CGO_ENABLED="0" ARG GOOS="linux" WORKDIR $GOPATH/src -RUN apk add --no-cache git=2.24.3-r0 && \ +RUN apk add --quiet --no-cache git && \ git config --global advice.detachedHead false && \ - git clone --single-branch https://gitea.com/gitea/tea -b v${TEA_VERSION} . && \ + if [ "${TEA_VERSION}" == "development" ]; \ + then \ + export TEA_VERSION="development-$(git ls-remote -q ${REPO} HEAD | cut -c-7)"; \ + else \ + export BRANCH_MODIFIER="-b v${TEA_VERSION}"; \ + fi && \ + git clone --single-branch ${REPO} ${BRANCH_MODIFIER} . && \ go get -v . && \ go build -v -a -ldflags "-X main.Version=${TEA_VERSION}" -o /tea . diff --git a/README.md b/README.md index fd97246..6e63e42 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ - export VERSION="0.2.0" - docker build . -t "gitea/tea:${VERSION}" --build-arg VERSION="${VERSION}" +...alternatively for development version: + +- docker build . -t "gitea/tea:latest" --build-arg VERSION="development" + +The version of Go used during the build can also be overridden by appending e.g. '--build-arg GOVERSION="1.13.10"' + ### Configuration - docker volume create tea - alias tea='docker run --rm -v tea:/app gitea/tea:'