- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.2k
 
Reduce incremental Docker build times #27998
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
Changes from 2 commits
104d1d1
              ee6a977
              1d42402
              52b039b
              b8a3fe7
              1f06340
              16d5668
              ab472b7
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -111,3 +111,7 @@ prime/ | |
| 
     | 
||
| # Manpage | ||
| /man | ||
| 
     | 
||
| Dockerfile | ||
| .dockerignore | ||
| .github/ | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -78,7 +78,6 @@ jobs: | |
| 
     | 
||
| docker: | ||
| - "Dockerfile" | ||
| - "Dockerfile.rootless" | ||
| - "docker/**" | ||
| - "Makefile" | ||
| 
     | 
||
| 
          
            
          
           | 
    ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -18,59 +18,104 @@ RUN apk --no-cache add \ | |
| && rm -rf /var/cache/apk/* | ||
| 
     | 
||
| # Setup repo | ||
| COPY . ${GOPATH}/src/code.gitea.io/gitea | ||
| WORKDIR ${GOPATH}/src/code.gitea.io/gitea | ||
| 
     | 
||
| COPY ./go.mod . | ||
| 
     | 
||
| RUN go mod download | ||
| 
     | 
||
| COPY package.json . | ||
| COPY package-lock.json . | ||
| 
     | 
||
| RUN npm install --no-save --verbose | ||
| 
     | 
||
| COPY . . | ||
                
       | 
||
| 
     | 
||
| # Checkout version if set | ||
| RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ | ||
| && make clean-all build | ||
| 
     | 
||
| # Begin env-to-ini build | ||
| RUN go build contrib/environment-to-ini/environment-to-ini.go | ||
| 
     | 
||
| # Copy local files | ||
| COPY docker/root /tmp/local | ||
| 
     | 
||
| # Set permissions | ||
| RUN chmod 755 /tmp/local/usr/bin/entrypoint \ | ||
| /tmp/local/usr/local/bin/gitea \ | ||
| /tmp/local/etc/s6/gitea/* \ | ||
| /tmp/local/etc/s6/openssh/* \ | ||
| /tmp/local/etc/s6/.s6-svscan/* \ | ||
| /go/src/code.gitea.io/gitea/gitea \ | ||
| /go/src/code.gitea.io/gitea/environment-to-ini | ||
| RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete | ||
| 
     | 
||
| FROM docker.io/library/alpine:3.18 | ||
| FROM docker.io/library/alpine:3.18 AS gitea-base | ||
| LABEL maintainer="[email protected]" | ||
| 
     | 
||
| EXPOSE 22 3000 | ||
| 
     | 
||
| RUN apk --no-cache add \ | ||
| bash \ | ||
| ca-certificates \ | ||
| curl \ | ||
| gettext \ | ||
| git \ | ||
| curl \ | ||
| gnupg \ | ||
| && rm -rf /var/cache/apk/* | ||
| 
     | 
||
| RUN addgroup -S -g 1000 git | ||
| 
     | 
||
| FROM gitea-base AS gitea-rootless | ||
| 
         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. How does this build work with the two tags in the same file? Would  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. You can see in the docker-dryrun workflow, that the first build-push-action build gitea-base and gitea. Then in the next build-push-action you can see the gitea-base layers have all been cached and only the gitea-rootless layers are run. If not specifying the target when building, docker build will export the final image "as the one to run".  | 
||
| LABEL maintainer="[email protected]" | ||
| 
     | 
||
| EXPOSE 2222 3000 | ||
| 
     | 
||
| RUN apk --no-cache add \ | ||
| dumb-init \ | ||
| && rm -rf /var/cache/apk/* | ||
| 
     | 
||
| RUN adduser \ | ||
| -S -H -D \ | ||
| -h /var/lib/gitea/git \ | ||
| -s /bin/bash \ | ||
| -u 1000 \ | ||
| -G git \ | ||
| git | ||
| 
     | 
||
| RUN mkdir -p /var/lib/gitea /etc/gitea | ||
| RUN chown git:git /var/lib/gitea /etc/gitea | ||
| 
     | 
||
| # Copy local files | ||
| COPY --chmod=755 docker/rootless /tmp/local | ||
| 
     | 
||
| COPY --from=build-env --chmod=755 --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea | ||
| COPY --from=build-env --chmod=755 --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini | ||
| COPY --from=build-env --chmod=644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh | ||
| 
     | 
||
| # git:git | ||
| USER 1000:1000 | ||
| ENV GITEA_WORK_DIR /var/lib/gitea | ||
| ENV GITEA_CUSTOM /var/lib/gitea/custom | ||
| ENV GITEA_TEMP /tmp/gitea | ||
| ENV TMPDIR /tmp/gitea | ||
| 
     | 
||
| # TODO add to docs the ability to define the ini to load (useful to test and revert a config) | ||
| ENV GITEA_APP_INI /etc/gitea/app.ini | ||
| ENV HOME "/var/lib/gitea/git" | ||
| VOLUME ["/var/lib/gitea", "/etc/gitea"] | ||
| WORKDIR /var/lib/gitea | ||
| 
     | 
||
| ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"] | ||
| CMD [] | ||
| 
     | 
||
| FROM gitea-base AS gitea | ||
| LABEL maintainer="[email protected]" | ||
| 
     | 
||
| EXPOSE 22 3000 | ||
| 
     | 
||
| RUN apk --no-cache add \ | ||
| linux-pam \ | ||
| openssh \ | ||
| s6 \ | ||
| sqlite \ | ||
| su-exec \ | ||
| gnupg \ | ||
| && rm -rf /var/cache/apk/* | ||
| 
     | 
||
| RUN addgroup \ | ||
| -S -g 1000 \ | ||
| git && \ | ||
| adduser \ | ||
| RUN adduser \ | ||
| -S -H -D \ | ||
| -h /data/git \ | ||
| -s /bin/bash \ | ||
| -u 1000 \ | ||
| -G git \ | ||
| git && \ | ||
| echo "git:*" | chpasswd -e | ||
| echo "git:*" | chpasswd -e | ||
| 
     | 
||
| ENV USER git | ||
| ENV GITEA_CUSTOM /data/gitea | ||
| 
        
          
        
         | 
    @@ -80,7 +125,8 @@ VOLUME ["/data"] | |
| ENTRYPOINT ["/usr/bin/entrypoint"] | ||
| CMD ["/bin/s6-svscan", "/etc/s6"] | ||
| 
     | 
||
| COPY --from=build-env /tmp/local / | ||
| COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea | ||
| COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini | ||
| COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh | ||
| COPY --chmod=755 docker/root /tmp/local | ||
| 
     | 
||
| COPY --from=build-env --chmod=755 /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea | ||
| COPY --from=build-env --chmod=755 /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini | ||
| COPY --from=build-env --chmod=644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.