From 94ca7e0d75a5252b395c99d00247df791736f6f3 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Thu, 16 Nov 2017 23:40:14 +0100 Subject: [PATCH 1/4] Setup docker multi-stage and little sugar at it --- .dockerignore | 5 ----- Dockerfile | 39 ++++++++++++++++++++++++++++++--------- docker/Makefile | 6 +++++- 3 files changed, 35 insertions(+), 15 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 9f87e69f5e55c..0000000000000 --- a/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -* -!gitea -!docker -!public -!templates diff --git a/Dockerfile b/Dockerfile index a99f76bc34cce..1c9d1c9dd68d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,42 @@ + +################################### +#Build stage +FROM golang:1.9-alpine3.7 AS build-env +LABEL maintainer="maintainers@gitea.io" + +ARG GITEA_VERSION +ARG TAGS="sqlite" +ENV TAGS "bindata $TAGS" + +#Build deps +RUN apk --no-cache add build-base git + +#Setup repo +COPY . ${GOPATH}/src/code.gitea.io/gitea +WORKDIR ${GOPATH}/src/code.gitea.io/gitea + +#Checkout version if set +RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ + && make clean generate build + FROM alpine:3.7 -LABEL maintainer="The Gitea Authors" +LABEL maintainer="maintainers@gitea.io" EXPOSE 22 3000 RUN apk --no-cache add \ - su-exec \ - ca-certificates \ - sqlite \ bash \ + ca-certificates \ + curl \ + gettext \ git \ linux-pam \ - s6 \ - curl \ openssh \ - gettext \ + s6 \ + sqlite \ + su-exec \ tzdata + RUN addgroup \ -S -g 1000 \ git && \ @@ -29,7 +51,6 @@ RUN addgroup \ ENV USER git ENV GITEA_CUSTOM /data/gitea -ENV GODEBUG=netdns=go VOLUME ["/data"] @@ -37,4 +58,4 @@ ENTRYPOINT ["/usr/bin/entrypoint"] CMD ["/bin/s6-svscan", "/etc/s6"] COPY docker / -COPY gitea /app/gitea/gitea +COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea diff --git a/docker/Makefile b/docker/Makefile index a816a2e44f702..7f55251860705 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -7,5 +7,9 @@ DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG) .PHONY: docker docker: - docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build docker build --disable-content-trust=false -t $(DOCKER_REF) . +# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite" . + +.PHONY: docker-build +docker-build: + docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build From 1fa605e817fb6ca3ce3f85183323d12ec7637af1 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Thu, 18 Jan 2018 12:17:32 +0100 Subject: [PATCH 2/4] Make codacy happy ? --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c9d1c9dd68d2..414daad4fc530 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ################################### #Build stage FROM golang:1.9-alpine3.7 AS build-env -LABEL maintainer="maintainers@gitea.io" +LABEL maintainer "maintainers@gitea.io" ARG GITEA_VERSION ARG TAGS="sqlite" @@ -20,7 +20,7 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ && make clean generate build FROM alpine:3.7 -LABEL maintainer="maintainers@gitea.io" +LABEL maintainer "maintainers@gitea.io" EXPOSE 22 3000 From 1dcd41ec9ba74dbc4db9939abe29fd2e6d64c06b Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Thu, 18 Jan 2018 14:37:07 +0100 Subject: [PATCH 3/4] Revert back to what the official docker documentation suggest Codacy don't seems to follow https://docs.docker.com/engine/reference/builder/#maintainer-deprecated --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 414daad4fc530..ffedb80fc322d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,6 @@ ################################### #Build stage FROM golang:1.9-alpine3.7 AS build-env -LABEL maintainer "maintainers@gitea.io" ARG GITEA_VERSION ARG TAGS="sqlite" @@ -20,7 +19,7 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ && make clean generate build FROM alpine:3.7 -LABEL maintainer "maintainers@gitea.io" +LABEL maintainer="maintainers@gitea.io" EXPOSE 22 3000 From 25d4d4f95184b11a868c22cc7749849b830aa1de Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Mon, 12 Mar 2018 10:22:43 +0100 Subject: [PATCH 4/4] Update golang version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ffedb80fc322d..8e3516418bd3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ################################### #Build stage -FROM golang:1.9-alpine3.7 AS build-env +FROM golang:1.10-alpine3.7 AS build-env ARG GITEA_VERSION ARG TAGS="sqlite"