system-config/docker/gitea/Dockerfile
Clark Boylan a5095d52bc Update Gitea to version 1.22
Changes made on our side to make this upgrade happen:

* Update the gitea checkout tag to v1.22.1
* Update the golang container version to 1.22 as gitea 1.22 has an
  undocumented hard dependency on golang 1.22 or newer.
* Update our overridden template files to match latest gitea template
  changes.
* Update our app.ini config to switch from [oauth2].ENABLE to
  [oauth2].ENABLED as the previous config string is deprecated and will
  be removed in 1.23.0 per:
    ...es/setting/oauth2.go:124:loadOAuth2From() [E] Deprecation: config
    option `[oauth2].ENABLE` presents, please use `[oauth2].ENABLED`
    instead because this fallback will be/has been removed in v1.23.0

The full release notes for this release can be found here:

  https://github.com/go-gitea/gitea/blob/v1.22.1/CHANGELOG.md

I've including the list of breaking changes below with my own
annotations on how/whether they affect us.

* BREAKING
  * Improve reverse proxy documents and clarify the AppURL guessing behavior (https://github.com/go-gitea/gitea/pull/31003) (https://github.com/go-gitea/gitea/pull/31020)
    * This isn't actually a breaking chagne but they have improved docs
      around how to properly set Host and X-Forwarded-Proto headers for
      gitea to enable better logging behind a reverse proxy. We should
      investigate.
  * Remember log in for a month by default (https://github.com/go-gitea/gitea/pull/30150)
    * Default was a week. We should consider rolling back to low values
      since we don't have real users.
  * Breaking summary for template refactoring (https://github.com/go-gitea/gitea/pull/29395)
    * All custom templates need to follow these changes
    * I don't think we're using any of the changed methods/functions in
      our templates. Testing should help confirm this.
  * Recommend/convert to use case-sensitive collation for MySQL/MSSQL (https://github.com/go-gitea/gitea/pull/28662)
    * This is the doctor update to address case sensitivity problems
      between git and gitea. We'll need to test this as part of our
      upgrade process and testing.
  * Make offline mode as default to not connect external avatar service by default (https://github.com/go-gitea/gitea/pull/28548)
    * We are already disabling gravatar. I think this will disable it
      harder.
  * Include public repos in the doer's dashboard for issue search (https://github.com/go-gitea/gitea/pull/28304)
    * This affects end user dashboard info rendering which we don't use.
  * Use restricted sanitizer for repository description (https://github.com/go-gitea/gitea/pull/28141)
    * We already control what goes into repo descriptions via
      projects.yaml. Shouldn't really affect us.
  * Support storage base path as prefix (https://github.com/go-gitea/gitea/pull/27827)
    * This change looks scary at first glance but appears to only affect
      minio storage systems (which is like an s3 abstraction layer). We
      store things to disk and shouldn't be affected if I read the PR
      correctly.
  * Enhanced auth token / remember me (https://github.com/go-gitea/gitea/pull/27606)
    * THis appears to improve security but it isn't clear what the
      effect on end users is. We'll see if our CI jobs are happy with
      new token generation I guess.
  * Rename the default themes to gitea-light, gitea-dark, gitea-auto (https://github.com/go-gitea/gitea/pull/27419)
    * If you didn't see the new themes, please remove the [ui].THEMES config option from app.ini
    * We don't do anything special for themes so this should noop for
      us.
  * Require MySQL 8.0, PostgreSQL 12, MSSQL 2012 (https://github.com/go-gitea/gitea/pull/27337)
    * Our version of MariaDB should be new enough to rough rough feature
      equivalent with MySQL 8.0 and newer. We might consider helping
      upstream add MariaDB testing if they haven't already though.

Change-Id: Ifb4f0d92d70bc06f717e6535f1b67a221e127180
2024-07-07 19:30:42 -07:00

158 lines
5.6 KiB
Docker

# syntax=docker/dockerfile:1.3
# Copyright (c) 2018 Red Hat, Inc.
# Copyright (c) 2016 The Gitea Authors
# Copyright (c) 2015 The Gogs Authors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Wed Oct 11 15:53:34 UTC 2023 - trigger rebuild
###################################
# Build stage
FROM docker.io/library/golang:1.22-bookworm AS build-env
LABEL maintainer="infra-root@openstack.org"
ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}
ARG GITEA_VERSION="v1.22.1"
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 \
&& curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_20.x bookworm main" | tee /etc/apt/sources.list.d/nodesource.list \
&& 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
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
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean-all build
# This is a utility the upstream image builds to translate env vars into
# the app.ini config. We primarily rely on ansible for this instead but
# build an include it anyway to stay in sync with upstream tooling.
RUN go build contrib/environment-to-ini/environment-to-ini.go
# 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
FROM docker.io/library/debian:bookworm-slim as base
RUN apt-get update \
&& apt-get -y dist-upgrade \
&& apt-get -y install \
bash \
ca-certificates \
curl \
gettext \
git \
openssh-client \
gnupg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN addgroup --system --gid 1000 git \
&& adduser \
--system --no-create-home --disabled-login \
--home /data/git \
--shell /bin/bash \
--uid 1000 \
--gid 1000 \
git \
&& echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd \
&& mkdir /custom
# Copy the /etc config files and entrypoint script
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/assets/img/
ENV GITEA_CUSTOM /custom
# This is used the the openssh container image to set sshd_config AllowUsers
# even though that container runs as root (due to low port selection).
# The main gitea web container also uses this USER env var for basic user
# setup in its entrypoint.
ENV USER git
###################################
# The gitea image
FROM base as gitea
RUN apt-get update && apt-get -y install pandoc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 3000
VOLUME ["/data"]
ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/usr/local/bin/gitea", "web"]
USER 1000:1000
###################################
# The openssh server image
FROM base as gitea-openssh
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confold" \
install openssh-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /run/sshd
COPY sshd-entrypoint.sh /usr/bin/entrypoint
EXPOSE 22
VOLUME ["/data"]
ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/usr/sbin/sshd", "-D", "-e"]