From 30279610b67688133a9e708759fcd374018262ed Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Mon, 9 Oct 2023 09:01:23 -0700 Subject: [PATCH] Update gitea to 1.21.3 Upgrade Gitea to 1.21.3. The changelogs for this release can be found here: https://github.com/go-gitea/gitea/blob/v1.21.3/CHANGELOG.md I have attempted to collect the interesting bits in this commit message as well as information on why we do or don't make changes to address these items. 1.21.0 * BREAKING * Restrict certificate type for builtin SSH server (https://github.com/go-gitea/gitea/pull/26789) * We don't use the builtin SSH server and don't use certificates for auth. Nothing to do here. * Refactor to use urfave/cli/v2 (https://github.com/go-gitea/gitea/pull/25959) * The major change here updated `gitea` to stop accepting `gitea web`'s command options. Our dockerfile is set up to use `CMD ["/usr/local/bin/gitea", "web"]` so we are not affected. * Move public asset files to the proper directory (https://github.com/go-gitea/gitea/pull/25907) * We update the testinfra test for robots.txt to more robustly check file contents. Previously it checked a very generic prefix which may indicate a generic file being served. * We move custom/public/img into custom/public/assets/img. Screenshots should be used to confirm this works as expected. * Remove commit status running and warning to align GitHub (https://github.com/go-gitea/gitea/pull/25839) (partially reverted: Restore warning commit status (https://github.com/go-gitea/gitea/pull/27504) (https://github.com/go-gitea/gitea/pull/27529)) * We don't rely on commit statuses as this is a read only replica of Gerrit. * Remove "CHARSET" config option for MySQL, always use "utf8mb4" (https://github.com/go-gitea/gitea/pull/25413) * We don't set [database].CHARSET. Doesn't affect us. * Set SSH_AUTHORIZED_KEYS_BACKUP to false (https://github.com/go-gitea/gitea/pull/25412) * We don't set this value explicitly so the default will flip from true to false for us. I don't think this is an issue because we keep track of our pubkeys in git. * SECURITY * Dont leak private users via extensions (https://github.com/go-gitea/gitea/pull/28023) (https://github.com/go-gitea/gitea/pull/28029) * We don't use private users. * Expanded minimum RSA Keylength to 3072 (https://github.com/go-gitea/gitea/pull/26604) * We have rotated keys used to replicate from gerrit to gitea to work around this. Now are keys are long enough to make gitea happy. * BUILD * Dockerfile small refactor (https://github.com/go-gitea/gitea/pull/27757) (https://github.com/go-gitea/gitea/pull/27826) * I've updated our Dockerfile to mimic these changes. Comment whitespace as well as how things are copied and chmoded in the build image have been updated. * TODO the file copies aren't working for us. I think due to how we ultimately clone the git repo. We use RUN but upstream is using COPY against the local build dir. I've aligned as best as I can, but we should see if we can do a similar COPY on our end. * Fix build errors on BSD (in BSDMakefile) (#27594) (#27608) * We don't run on BSD. * Fully replace drone with actions (#27556) (#27575) * This is how upstream builds their images. Doesn't affect our builds. * Enable markdownlint no-duplicate-header (#27500) (#27506) * Build time linters are somethign we don't care too much about on our end. * Enable production source maps for index.js, fix CSS sourcemaps (https://github.com/go-gitea/gitea/pull/27291) (https://github.com/go-gitea/gitea/pull/27295) * This emits a source map for index.js which can be used for in browser debugging. Don't think this is anything we need to take action on. * Update snap package (#27021) * We don't use a snap package. * Bump go to 1.21 (https://github.com/go-gitea/gitea/pull/26608) * Our go version is updated in the Dockerfile. * Bump xgo to go-1.21.x and node to 20 in release-version (https://github.com/go-gitea/gitea/pull/26589) * Our node version is updated in the Dockerfile. * Add template linting via djlint (#25212) * Build time linters are somethign we don't care too much about on our end. 1.21.1 * SECURITY * Fix comment permissions (https://github.com/go-gitea/gitea/pull/28213) (https://github.com/go-gitea/gitea/pull/28216) * This affects disclosure of private repo content. We don't have private repos so shouldn't be affected. 1.21.2 * SECURITY * Rebuild with recently released golang version * We'll automatically rebuild with newer golang too. * Fix missing check (https://github.com/go-gitea/gitea/pull/28406) (https://github.com/go-gitea/gitea/pull/28411) * There is minimal info here but it appears to be related to issues. We don't use issues so shouldn't affect us. * Do some missing checks (https://github.com/go-gitea/gitea/pull/28423) (https://github.com/go-gitea/gitea/pull/28432) * There is minimal info here but it appears to be related to checks around private repos. We don't use private repos so this shouldn't affect us. 1.21.3 * SECURITY * Update golang.org/x/crypto (https://github.com/go-gitea/gitea/pull/28519) * This addresses recent concerns found in ssh for gitea's built in ssh implementation. We use openssh as provided by debian so will rely on our distro to provide fixes. Finally 1.21.x broke rendering of code search templates. The issue is here: https://github.com/go-gitea/gitea/issues/28607. To address this I've vendored the two fixed template files (https://github.com/go-gitea/gitea/pull/28576/files)into our custom template dirs. Once upstream makes a release with these fixes we can drop the custom files entirely as we don't override anything special in them. Change-Id: Id714826a9bc7682403afcf90f2761db8c84eacbf --- docker/gitea/Dockerfile | 42 ++++-- .../{ => assets}/img/avatar_default.png | Bin .../public/{ => assets}/img/etherpad.svg | 0 .../custom/public/{ => assets}/img/gerrit.svg | 0 .../custom/public/{ => assets}/img/git.svg | 0 .../public/{ => assets}/img/gitea-safari.svg | 0 .../custom/public/{ => assets}/img/zuul.svg | 0 .../custom/templates/base/head_navbar.tmpl | 136 +++++++++--------- .../custom/templates/code/searchresults.tmpl | 43 ++++++ docker/gitea/custom/templates/home.tmpl | 2 +- .../gitea/custom/templates/repo/header.tmpl | 103 ++++++------- .../gitea/custom/templates/repo/search.tmpl | 73 ++++++++++ testinfra/test_gitea.py | 1 + 13 files changed, 260 insertions(+), 140 deletions(-) rename docker/gitea/custom/public/{ => assets}/img/avatar_default.png (100%) rename docker/gitea/custom/public/{ => assets}/img/etherpad.svg (100%) rename docker/gitea/custom/public/{ => assets}/img/gerrit.svg (100%) rename docker/gitea/custom/public/{ => assets}/img/git.svg (100%) rename docker/gitea/custom/public/{ => assets}/img/gitea-safari.svg (100%) rename docker/gitea/custom/public/{ => assets}/img/zuul.svg (100%) create mode 100644 docker/gitea/custom/templates/code/searchresults.tmpl create mode 100644 docker/gitea/custom/templates/repo/search.tmpl diff --git a/docker/gitea/Dockerfile b/docker/gitea/Dockerfile index 7296ad3e2d..518af21408 100644 --- a/docker/gitea/Dockerfile +++ b/docker/gitea/Dockerfile @@ -24,15 +24,18 @@ # Wed Oct 11 15:53:34 UTC 2023 - trigger rebuild ################################### -#Build stage -FROM docker.io/library/golang:1.20-bookworm AS build-env +# Build stage +FROM docker.io/library/golang:1.21-bookworm AS build-env LABEL maintainer="infra-root@openstack.org" -ARG GITEA_VERSION="v1.20.6" -ENV TAGS "bindata $TAGS" +ARG GOPROXY +ENV GOPROXY ${GOPROXY:-direct} -#Build deps +ARG GITEA_VERSION="v1.21.3" +ENV TAGS "bindata timetzdata $TAGS" + +# Build deps RUN apt-get update \ && apt-get -y dist-upgrade \ && apt-get -y install build-essential git apt-transport-https curl gnupg2 \ @@ -42,11 +45,11 @@ RUN apt-get update \ && apt-get -q --option "Dpkg::Options::=--force-confold" --assume-yes install nodejs \ && mkdir -p ${GOPATH}/src/code.gitea.io/gitea -#Setup repo +# Setup repo RUN git clone https://github.com/go-gitea/gitea ${GOPATH}/src/code.gitea.io/gitea WORKDIR ${GOPATH}/src/code.gitea.io/gitea -#Checkout version if set +# Checkout version if set RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ && make clean-all build @@ -55,11 +58,22 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ # build an include it anyway to stay in sync with upstream tooling. RUN go build contrib/environment-to-ini/environment-to-ini.go -# Make things executable since they aren't all that way in git -RUN chmod 755 gitea \ - environment-to-ini \ - docker/root/usr/bin/entrypoint \ - docker/root/usr/local/bin/gitea +# TODO upstream performs this COPY then chmods the docker/root/ prefixed +# files below against /tmp/local. The copy fails for us due to some bad +# interaction with docker image build caching. I think due to how we clone +# the repo above. We should align better with upstream if possible. +## Copy local files +# COPY docker/root /tmp/local + +# Set permissions +RUN chmod 755 docker/root/usr/bin/entrypoint \ + docker/root/usr/local/bin/gitea \ + docker/root/etc/s6/gitea/* \ + docker/root/etc/s6/openssh/* \ + docker/root/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 ################################### # Basic system setup common to all containers in our pod @@ -75,7 +89,6 @@ RUN apt-get update \ gettext \ git \ openssh-client \ - tzdata \ gnupg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -97,11 +110,12 @@ COPY --from=build-env /go/src/code.gitea.io/gitea/docker/root / # Copy the app 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 our custom templates and some additional image files COPY custom/ /custom/ # Copy our opendev logo contents to the custom location -RUN --mount=type=bind,from=opendevorg/assets,target=/tmp/assets cp -r /tmp/assets/* /custom/public/img/ +RUN --mount=type=bind,from=opendevorg/assets,target=/tmp/assets cp -r /tmp/assets/* /custom/public/assets/img/ ENV GITEA_CUSTOM /custom # This is used the the openssh container image to set sshd_config AllowUsers diff --git a/docker/gitea/custom/public/img/avatar_default.png b/docker/gitea/custom/public/assets/img/avatar_default.png similarity index 100% rename from docker/gitea/custom/public/img/avatar_default.png rename to docker/gitea/custom/public/assets/img/avatar_default.png diff --git a/docker/gitea/custom/public/img/etherpad.svg b/docker/gitea/custom/public/assets/img/etherpad.svg similarity index 100% rename from docker/gitea/custom/public/img/etherpad.svg rename to docker/gitea/custom/public/assets/img/etherpad.svg diff --git a/docker/gitea/custom/public/img/gerrit.svg b/docker/gitea/custom/public/assets/img/gerrit.svg similarity index 100% rename from docker/gitea/custom/public/img/gerrit.svg rename to docker/gitea/custom/public/assets/img/gerrit.svg diff --git a/docker/gitea/custom/public/img/git.svg b/docker/gitea/custom/public/assets/img/git.svg similarity index 100% rename from docker/gitea/custom/public/img/git.svg rename to docker/gitea/custom/public/assets/img/git.svg diff --git a/docker/gitea/custom/public/img/gitea-safari.svg b/docker/gitea/custom/public/assets/img/gitea-safari.svg similarity index 100% rename from docker/gitea/custom/public/img/gitea-safari.svg rename to docker/gitea/custom/public/assets/img/gitea-safari.svg diff --git a/docker/gitea/custom/public/img/zuul.svg b/docker/gitea/custom/public/assets/img/zuul.svg similarity index 100% rename from docker/gitea/custom/public/img/zuul.svg rename to docker/gitea/custom/public/assets/img/zuul.svg diff --git a/docker/gitea/custom/templates/base/head_navbar.tmpl b/docker/gitea/custom/templates/base/head_navbar.tmpl index c359f99b92..c7cef0d6c6 100644 --- a/docker/gitea/custom/templates/base/head_navbar.tmpl +++ b/docker/gitea/custom/templates/base/head_navbar.tmpl @@ -3,86 +3,86 @@ {{$notificationUnreadCount = call .NotificationUnreadCount}} {{end}} -