From 195bd2199c591f49f0f80eb70f425e2725313bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Tue, 30 Mar 2021 19:13:23 +0800 Subject: [PATCH] contributed container build definition (#350) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit as discussed with @noerw on Discord Co-authored-by: Tamás Gérczei Reviewed-on: https://gitea.com/gitea/tea/pulls/350 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Norwin Reviewed-by: techknowlogick Co-authored-by: Tamás Gérczei Co-committed-by: Tamás Gérczei --- Dockerfile | 25 +++++++++++++++++++++++++ Makefile | 6 ++++++ 2 files changed, 31 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..695f52d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +ARG GOVERSION="1.16.2" + +FROM golang:${GOVERSION}-alpine AS buildenv + +ARG CGO_ENABLED="0" +ARG GOOS="linux" + +COPY . $GOPATH/src/ +WORKDIR $GOPATH/src + +RUN apk add --quiet --no-cache \ + make \ + git && \ + make build + +FROM scratch +ARG VERSION="0.7.0" +LABEL org.opencontainers.image.title="tea - CLI for Gitea - git with a cup of tea" +LABEL org.opencontainers.image.description="A command line tool to interact with Gitea servers" +LABEL org.opencontainers.image.version="${VERSION}" +LABEL org.opencontainers.image.authors="Tamás Gérczei " +LABEL org.opencontainers.image.vendor="The Gitea Authors" +COPY --from=buildenv /go/src/tea / +ENV HOME="/app" +ENTRYPOINT ["/tea"] diff --git a/Makefile b/Makefile index ada6f14..e79c0f3 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,8 @@ else TEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') endif +TEA_VERSION_TAG ?= $(shell sed 's/+/_/' <<< $(TEA_VERSION)) + LDFLAGS := -X "main.Version=$(TEA_VERSION)" -X "main.Tags=$(TAGS)" PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/) @@ -139,6 +141,10 @@ build: $(EXECUTABLE) $(EXECUTABLE): $(SOURCES) $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ +.PHONY: build-image +build-image: + docker build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) . + .PHONY: release release: release-dirs release-os release-compress release-check