From d4d44cf283299d5cb3b6dbe761b7e24f70a008bc Mon Sep 17 00:00:00 2001 From: Oleks Date: Mon, 11 May 2026 16:57:08 +0300 Subject: [PATCH] chore(ddev): local dev environment for testing the Projects API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ddev start` provisions: - web container: Debian + Go 1.26.3 + node 24, builds gitea via `ddev build-gitea` - db: postgres 17 - router: https://gitea.ddev.site → gitea on container port 3000 First-run steps: ddev start ddev build-gitea ddev restart ddev exec './gitea --config .ddev/gitea/app.ini admin user create \ --admin --username ddev --password ddev1234567890 \ --email ddev@example.com --must-change-password=false' .ddev/.gitignore uses a whitelist: only the 6 files we authored are tracked; DDEV's generated content (compose files, provider templates, snapshots, gocache, gitea runtime data) is ignored. --- .ddev/.gitignore | 17 ++++++++++ .ddev/commands/web/build-gitea | 10 ++++++ .ddev/config.yaml | 31 ++++++++++++++++++ .ddev/gitea/.gitignore | 5 +++ .ddev/gitea/app.ini | 60 ++++++++++++++++++++++++++++++++++ .ddev/web-build/Dockerfile | 25 ++++++++++++++ 6 files changed, 148 insertions(+) create mode 100644 .ddev/.gitignore create mode 100755 .ddev/commands/web/build-gitea create mode 100644 .ddev/config.yaml create mode 100644 .ddev/gitea/.gitignore create mode 100644 .ddev/gitea/app.ini create mode 100644 .ddev/web-build/Dockerfile diff --git a/.ddev/.gitignore b/.ddev/.gitignore new file mode 100644 index 0000000000..643d6148b9 --- /dev/null +++ b/.ddev/.gitignore @@ -0,0 +1,17 @@ +# Whitelist approach: ignore everything in .ddev by default, then re-include +# the files we author. DDEV regenerates the rest on `ddev start`. +* +!.gitignore +!config.yaml +!web-build/ +web-build/* +!web-build/Dockerfile +!commands/ +commands/* +!commands/web/ +commands/web/* +!commands/web/build-gitea +!gitea/ +gitea/* +!gitea/app.ini +!gitea/.gitignore diff --git a/.ddev/commands/web/build-gitea b/.ddev/commands/web/build-gitea new file mode 100755 index 0000000000..289842b082 --- /dev/null +++ b/.ddev/commands/web/build-gitea @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +## Description: Build the gitea backend binary inside the web container +## Usage: build-gitea +## Example: ddev build-gitea + +set -eu +cd /var/www/html +echo "Building gitea backend (cgo, sqlite + sqlite_unlock_notify tags)..." +make backend +echo "Done. Restart the daemon: ddev restart" diff --git a/.ddev/config.yaml b/.ddev/config.yaml new file mode 100644 index 0000000000..3645af5c03 --- /dev/null +++ b/.ddev/config.yaml @@ -0,0 +1,31 @@ +name: gitea +type: generic +docroot: . +webserver_type: generic +nodejs_version: "24" +corepack_enable: true + +webimage_extra_packages: + - make + - build-essential + - libsqlite3-dev + +database: + type: postgres + version: "17" + +# Route HTTPS (gitea.ddev.site) to gitea's port 3000 inside the web container +web_extra_exposed_ports: + - name: gitea + container_port: 3000 + http_port: 80 + https_port: 443 + +web_extra_daemons: + - name: gitea-web + command: "/var/www/html/gitea web --config /var/www/html/.ddev/gitea/app.ini" + directory: /var/www/html + +web_environment: + - GITEA_WORK_DIR=/var/www/html + - GITEA_CUSTOM=/var/www/html/.ddev/gitea diff --git a/.ddev/gitea/.gitignore b/.ddev/gitea/.gitignore new file mode 100644 index 0000000000..2feb5765a4 --- /dev/null +++ b/.ddev/gitea/.gitignore @@ -0,0 +1,5 @@ +data/ +repositories/ +indexers/ +queues/ +log/ diff --git a/.ddev/gitea/app.ini b/.ddev/gitea/app.ini new file mode 100644 index 0000000000..5f801b6f68 --- /dev/null +++ b/.ddev/gitea/app.ini @@ -0,0 +1,60 @@ +APP_NAME = Gitea (DDEV) +RUN_MODE = dev +WORK_PATH = /var/www/html + +[server] +PROTOCOL = http +HTTP_ADDR = 0.0.0.0 +HTTP_PORT = 3000 +DOMAIN = gitea.ddev.site +ROOT_URL = https://gitea.ddev.site/ +SSH_DOMAIN = gitea.ddev.site +DISABLE_SSH = true +APP_DATA_PATH = /var/www/html/.ddev/gitea/data +LFS_START_SERVER = false +OFFLINE_MODE = true + +[database] +DB_TYPE = postgres +HOST = db:5432 +NAME = db +USER = db +PASSWD = db +SSL_MODE = disable +SCHEMA = public + +[repository] +ROOT = /var/www/html/.ddev/gitea/repositories + +[security] +INSTALL_LOCK = true +SECRET_KEY = ddev-gitea-secret-key-placeholder +INTERNAL_TOKEN = ddev-gitea-internal-token-placeholder + +[service] +DISABLE_REGISTRATION = false +REQUIRE_SIGNIN_VIEW = false +DEFAULT_KEEP_EMAIL_PRIVATE = false +DEFAULT_ALLOW_CREATE_ORGANIZATION = true + +[log] +ROOT_PATH = /var/www/html/.ddev/gitea/log +MODE = console +LEVEL = info + +[session] +PROVIDER = memory + +[mailer] +ENABLED = false + +[indexer] +ISSUE_INDEXER_PATH = /var/www/html/.ddev/gitea/indexers/issues.bleve +REPO_INDEXER_PATH = /var/www/html/.ddev/gitea/indexers/repos.bleve + +[queue] +TYPE = level +DATADIR = /var/www/html/.ddev/gitea/queues + +[oauth2] +JWT_SECRET = Ox7IRtBouaVq1kogqXCOce5NZLi0OL42SbkRKLZvHY4 diff --git a/.ddev/web-build/Dockerfile b/.ddev/web-build/Dockerfile new file mode 100644 index 0000000000..18c9b6d27e --- /dev/null +++ b/.ddev/web-build/Dockerfile @@ -0,0 +1,25 @@ +ARG BASE_IMAGE +FROM $BASE_IMAGE + +# Install Go 1.26 — DDEV's base image doesn't ship Go +ENV GO_VERSION=1.26.3 +RUN set -eux; \ + arch="$(dpkg --print-architecture)"; \ + case "$arch" in \ + amd64) GO_ARCH=amd64 ;; \ + arm64) GO_ARCH=arm64 ;; \ + *) echo "unsupported arch $arch" >&2; exit 1 ;; \ + esac; \ + curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" -o /tmp/go.tgz; \ + tar -C /usr/local -xzf /tmp/go.tgz; \ + rm /tmp/go.tgz +ENV GOPATH=/var/www/html/.ddev/gocache/path +ENV GOCACHE=/var/www/html/.ddev/gocache/build +ENV PATH="/usr/local/go/bin:${GOPATH}/bin:${PATH}" + +# git, build-essential, sqlite, and node 24 are already in the ddev-webserver base +RUN go version + +# Pre-warm pnpm cache root for the build step +ENV PNPM_HOME=/var/www/html/.ddev/gocache/pnpm +ENV PATH="${PNPM_HOME}:${PATH}"