From 34e86ef5db4611b3f8ba9ef1de19bac2b75df212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Mon, 15 Mar 2021 19:34:15 +0100 Subject: [PATCH 1/6] contributed container build definition --- contrib/Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ contrib/hooks/build | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 contrib/Dockerfile create mode 100644 contrib/hooks/build diff --git a/contrib/Dockerfile b/contrib/Dockerfile new file mode 100644 index 0000000..f0c52c1 --- /dev/null +++ b/contrib/Dockerfile @@ -0,0 +1,36 @@ +ARG GOVERSION="1.16.2" + +FROM golang:${GOVERSION}-alpine AS buildenv + +ARG REPO="https://gitea.com/gitea/tea.git" + +ARG VERSION="0.7.0" +ENV TEA_VERSION="${VERSION}" + +ARG CGO_ENABLED="0" +ARG GOOS="linux" + +ARG BUILD_DATE + +WORKDIR $GOPATH/src + +RUN apk add --quiet --no-cache git && \ + git config --global advice.detachedHead false && \ + git clone --single-branch ${REPO} -b v${TEA_VERSION} . && \ + go get -v . && \ + go build -v -a -ldflags "-X main.Version=${TEA_VERSION}" -o /tea . + +FROM scratch +ARG BUILD_DATE +ARG VERSION="0.7.0" +LABEL org.opencontainers.image.title="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.url="https://gitea.com/gitea/tea" +LABEL org.opencontainers.image.authors="Tamás Gérczei " +LABEL org.opencontainers.image.created="${BUILD_DATE}" +LABEL org.opencontainers.image.source="https://github.com/tgerczei/conteaner" +LABEL org.opencontainers.image.vendor="Gérczei Tamás E.V." +COPY --from=buildenv /tea / +ENV HOME="/app" +ENTRYPOINT ["/tea"] diff --git a/contrib/hooks/build b/contrib/hooks/build new file mode 100644 index 0000000..a43d367 --- /dev/null +++ b/contrib/hooks/build @@ -0,0 +1,2 @@ +#!/bin/sh +docker build --build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) -t $IMAGE_NAME . -- 2.40.1 From 651572c2074eb0205d36305b8cc2c1bab7401331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Tue, 16 Mar 2021 16:51:45 +0100 Subject: [PATCH 2/6] updated image labels --- contrib/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index f0c52c1..55479ec 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -23,14 +23,14 @@ RUN apk add --quiet --no-cache git && \ FROM scratch ARG BUILD_DATE ARG VERSION="0.7.0" -LABEL org.opencontainers.image.title="Gitea - Git with a cup of tea" +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.url="https://gitea.com/gitea/tea" LABEL org.opencontainers.image.authors="Tamás Gérczei " LABEL org.opencontainers.image.created="${BUILD_DATE}" -LABEL org.opencontainers.image.source="https://github.com/tgerczei/conteaner" -LABEL org.opencontainers.image.vendor="Gérczei Tamás E.V." +LABEL org.opencontainers.image.source="https://gitea.com/gitea/tea" +LABEL org.opencontainers.image.vendor="The Gitea Authors" COPY --from=buildenv /tea / ENV HOME="/app" ENTRYPOINT ["/tea"] -- 2.40.1 From 2d327f5247a0cc0ea4edb07f72df407dd6e370ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Tue, 16 Mar 2021 19:35:33 +0100 Subject: [PATCH 3/6] moved image build definition to project root, deleted build hook, removed labels included by Drone --- contrib/Dockerfile => Dockerfile | 3 --- contrib/hooks/build | 2 -- 2 files changed, 5 deletions(-) rename contrib/Dockerfile => Dockerfile (83%) delete mode 100644 contrib/hooks/build diff --git a/contrib/Dockerfile b/Dockerfile similarity index 83% rename from contrib/Dockerfile rename to Dockerfile index 55479ec..8a40f79 100644 --- a/contrib/Dockerfile +++ b/Dockerfile @@ -26,10 +26,7 @@ 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.url="https://gitea.com/gitea/tea" LABEL org.opencontainers.image.authors="Tamás Gérczei " -LABEL org.opencontainers.image.created="${BUILD_DATE}" -LABEL org.opencontainers.image.source="https://gitea.com/gitea/tea" LABEL org.opencontainers.image.vendor="The Gitea Authors" COPY --from=buildenv /tea / ENV HOME="/app" diff --git a/contrib/hooks/build b/contrib/hooks/build deleted file mode 100644 index a43d367..0000000 --- a/contrib/hooks/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -docker build --build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) -t $IMAGE_NAME . -- 2.40.1 From 6453d631c3f32ca3657f0db7d8bb8308a4eb43e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Tue, 16 Mar 2021 20:35:37 +0100 Subject: [PATCH 4/6] added target 'build-image' to Makefile, will build from local sources, removed build arg 'BUILD_DATE' --- Dockerfile | 11 ++--------- Makefile | 6 ++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a40f79..a9a4288 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,26 +2,19 @@ ARG GOVERSION="1.16.2" FROM golang:${GOVERSION}-alpine AS buildenv -ARG REPO="https://gitea.com/gitea/tea.git" - ARG VERSION="0.7.0" ENV TEA_VERSION="${VERSION}" ARG CGO_ENABLED="0" ARG GOOS="linux" -ARG BUILD_DATE - +COPY . $GOPATH/src/ WORKDIR $GOPATH/src -RUN apk add --quiet --no-cache git && \ - git config --global advice.detachedHead false && \ - git clone --single-branch ${REPO} -b v${TEA_VERSION} . && \ - go get -v . && \ +RUN go get -v . && \ go build -v -a -ldflags "-X main.Version=${TEA_VERSION}" -o /tea . FROM scratch -ARG BUILD_DATE 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" diff --git a/Makefile b/Makefile index ada6f14..bb30fad 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: + podman build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) . + .PHONY: release release: release-dirs release-os release-compress release-check -- 2.40.1 From 94442dc64f2b2b15a9b814666f903c660a5010ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Tue, 16 Mar 2021 20:38:09 +0100 Subject: [PATCH 5/6] switched to Docker from podman --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bb30fad..e79c0f3 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,7 @@ $(EXECUTABLE): $(SOURCES) .PHONY: build-image build-image: - podman build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) . + docker build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) . .PHONY: release release: release-dirs release-os release-compress release-check -- 2.40.1 From 2b935b75add1af8fd05c357a10e8ae713f6ea37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20G=C3=A9rczei?= Date: Mon, 22 Mar 2021 08:14:38 +0100 Subject: [PATCH 6/6] will now produce image via make --- Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9a4288..695f52d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,17 +2,16 @@ ARG GOVERSION="1.16.2" FROM golang:${GOVERSION}-alpine AS buildenv -ARG VERSION="0.7.0" -ENV TEA_VERSION="${VERSION}" - ARG CGO_ENABLED="0" ARG GOOS="linux" COPY . $GOPATH/src/ WORKDIR $GOPATH/src -RUN go get -v . && \ - go build -v -a -ldflags "-X main.Version=${TEA_VERSION}" -o /tea . +RUN apk add --quiet --no-cache \ + make \ + git && \ + make build FROM scratch ARG VERSION="0.7.0" @@ -21,6 +20,6 @@ LABEL org.opencontainers.image.description="A command line tool to interact with 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 /tea / +COPY --from=buildenv /go/src/tea / ENV HOME="/app" ENTRYPOINT ["/tea"] -- 2.40.1