-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Docker multi-stage #2927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker multi-stage #2927
Changes from all commits
94ca7e0
1fa605e
1dcd41e
3825a13
25d4d4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,41 @@ | ||
|
||
################################### | ||
#Build stage | ||
FROM golang:1.10-alpine3.7 AS build-env | ||
|
||
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="[email protected]" | ||
|
||
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,12 +50,11 @@ RUN addgroup \ | |
|
||
ENV USER git | ||
ENV GITEA_CUSTOM /data/gitea | ||
ENV GODEBUG=netdns=go | ||
|
||
VOLUME ["/data"] | ||
|
||
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 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And even if this target will stay in Makefile, I think it would be reasonable to switch it to golang:1.9-alpine3.6 with content trust enabled as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @0rzech for docker-build it is not possible golang:1.9-alpine3.6 is missing some build tools. I get them in the build stage of the Dockerfile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sapk You're right. I forgot it misses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way gitea binary will become writable for user git. This is out of scope for this PR - I'm just writing it for future reference. Not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure ? I haven't tested but that should be root the owner and permissions should be the same as go build result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure. It's because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that should be fix but it was already the case before and not introduce by this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. This is exactly why I wrote:
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry misread, and thinking that specific line introduce that XD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. ;)