Skip to content

Commit 0e26db8

Browse files
sapklafriks
authored andcommitted
Docker multi-stage (#2927)
* Setup docker multi-stage and little sugar at it * Make codacy happy ? * Revert back to what the official docker documentation suggest Codacy don't seems to follow https://docs.docker.com/engine/reference/builder/#maintainer-deprecated * Update golang version
1 parent b333e71 commit 0e26db8

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

.dockerignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

Dockerfile

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1+
2+
###################################
3+
#Build stage
4+
FROM golang:1.10-alpine3.7 AS build-env
5+
6+
ARG GITEA_VERSION
7+
ARG TAGS="sqlite"
8+
ENV TAGS "bindata $TAGS"
9+
10+
#Build deps
11+
RUN apk --no-cache add build-base git
12+
13+
#Setup repo
14+
COPY . ${GOPATH}/src/code.gitea.io/gitea
15+
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
16+
17+
#Checkout version if set
18+
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
19+
&& make clean generate build
20+
121
FROM alpine:3.7
2-
LABEL maintainer="The Gitea Authors"
22+
LABEL maintainer="[email protected]"
323

424
EXPOSE 22 3000
525

626
RUN apk --no-cache add \
7-
su-exec \
8-
ca-certificates \
9-
sqlite \
1027
bash \
28+
ca-certificates \
29+
curl \
30+
gettext \
1131
git \
1232
linux-pam \
13-
s6 \
14-
curl \
1533
openssh \
16-
gettext \
34+
s6 \
35+
sqlite \
36+
su-exec \
1737
tzdata
38+
1839
RUN addgroup \
1940
-S -g 1000 \
2041
git && \
@@ -29,12 +50,11 @@ RUN addgroup \
2950

3051
ENV USER git
3152
ENV GITEA_CUSTOM /data/gitea
32-
ENV GODEBUG=netdns=go
3353

3454
VOLUME ["/data"]
3555

3656
ENTRYPOINT ["/usr/bin/entrypoint"]
3757
CMD ["/bin/s6-svscan", "/etc/s6"]
3858

3959
COPY docker /
40-
COPY gitea /app/gitea/gitea
60+
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea

docker/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
77

88
.PHONY: docker
99
docker:
10-
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
1110
docker build --disable-content-trust=false -t $(DOCKER_REF) .
11+
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite" .
12+
13+
.PHONY: docker-build
14+
docker-build:
15+
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

0 commit comments

Comments
 (0)