Skip to content

Commit 94ca7e0

Browse files
committed
Setup docker multi-stage and little sugar at it
1 parent 095fb9f commit 94ca7e0

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

.dockerignore

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

Dockerfile

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

425
EXPOSE 22 3000
526

627
RUN apk --no-cache add \
7-
su-exec \
8-
ca-certificates \
9-
sqlite \
1028
bash \
29+
ca-certificates \
30+
curl \
31+
gettext \
1132
git \
1233
linux-pam \
13-
s6 \
14-
curl \
1534
openssh \
16-
gettext \
35+
s6 \
36+
sqlite \
37+
su-exec \
1738
tzdata
39+
1840
RUN addgroup \
1941
-S -g 1000 \
2042
git && \
@@ -29,12 +51,11 @@ RUN addgroup \
2951

3052
ENV USER git
3153
ENV GITEA_CUSTOM /data/gitea
32-
ENV GODEBUG=netdns=go
3354

3455
VOLUME ["/data"]
3556

3657
ENTRYPOINT ["/usr/bin/entrypoint"]
3758
CMD ["/bin/s6-svscan", "/etc/s6"]
3859

3960
COPY docker /
40-
COPY gitea /app/gitea/gitea
61+
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)