[PR #2201] [MERGED] Add environment variable support for Docker image #16284

Closed
opened 2025-11-02 12:06:42 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/2201
Author: @twang2218
Created: 7/23/2017
Status: Merged
Merged: 10/31/2017
Merged by: @lunny

Base: masterHead: docker-variables


📝 Commits (2)

  • 2600cf6 Add environment variable support for Docker image
  • 0fca9c1 Merge branch 'master' into docker-variables

📊 Changes

5 files changed (+42 additions, -2 deletions)

View changed files

📝 Dockerfile (+1 -0)
📝 Dockerfile.aarch64 (+1 -0)
📝 Dockerfile.rpi (+1 -0)
📝 docker/etc/s6/gitea/setup (+23 -1)
📝 docker/etc/templates/app.ini (+16 -1)

📄 Description

  • Add gettext dependencies as we need envsubst command;
  • Modified s6's gitea setup script, instead of cp the template if no
    app.ini exist, it will substitude the envvars and generate the new
    app.ini;
  • Make /docker/etc/templates/app.ini a template contains environment
    variables;

The following environment variable can be set:

  • APP_NAME: (default: Gitea: Git with a cup of tea)
  • APP_MODE: (default: dev)
  • [server]:
    • SSH_DOMAIN: (default: localhost)
    • HTTP_PORT: (default: 3000)
    • ROOT_URL: (default: '')
    • DISABLE_SSH: (default: false)
    • SSH_PORT: (default: 22)
  • [database]:
    • DB_TYPE: (default: sqlite3)
    • DB_HOST: (default: localhost:3306)
    • DB_NAME: (default: gitea)
    • DB_USER: (default: root)
    • DB_PASSWD: (default: ``)
  • [security]:
    • INSTALL_LOCK: (default: true)
    • SECRET_KEY: (default: JPuNRXxX2G)

With these environment variables available, user can easily run the docker image with minor modifications without creating an custom app.ini, such as:

$ docker run -d -p 3000:3000 \
    -e ROOT_URL=http://dev.example.com \
    -e DB_TYPE=mysql \
    -e DB_HOST=1.2.3.4:3306 \
    -e DB_USER=gitea \
    -e DB_PASSWD=Sup3rPassw0rd \
    -e SECRET_KEY=Sup3r3ecre7 \
    gitea/gitea:latest

Signed-off-by: Tao Wang twang2218@gmail.com


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/2201 **Author:** [@twang2218](https://github.com/twang2218) **Created:** 7/23/2017 **Status:** ✅ Merged **Merged:** 10/31/2017 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `docker-variables` --- ### 📝 Commits (2) - [`2600cf6`](https://github.com/go-gitea/gitea/commit/2600cf63fbf017bd871c360ef7b20db8c52c767b) Add environment variable support for Docker image - [`0fca9c1`](https://github.com/go-gitea/gitea/commit/0fca9c1276fbae0627573208b91866b52a42957b) Merge branch 'master' into docker-variables ### 📊 Changes **5 files changed** (+42 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+1 -0) 📝 `Dockerfile.aarch64` (+1 -0) 📝 `Dockerfile.rpi` (+1 -0) 📝 `docker/etc/s6/gitea/setup` (+23 -1) 📝 `docker/etc/templates/app.ini` (+16 -1) </details> ### 📄 Description * Add `gettext` dependencies as we need `envsubst` command; * Modified s6's gitea setup script, instead of `cp` the template if no `app.ini` exist, it will substitude the envvars and generate the new `app.ini`; * Make `/docker/etc/templates/app.ini` a template contains environment variables; The following environment variable can be set: * `APP_NAME`: (default: `Gitea: Git with a cup of tea`) * `APP_MODE`: (default: `dev`) * [server]: * `SSH_DOMAIN`: (default: `localhost`) * `HTTP_PORT`: (default: `3000`) * `ROOT_URL`: (default: '') * `DISABLE_SSH`: (default: `false`) * `SSH_PORT`: (default: `22`) * [database]: * `DB_TYPE`: (default: `sqlite3`) * `DB_HOST`: (default: `localhost:3306`) * `DB_NAME`: (default: `gitea`) * `DB_USER`: (default: `root`) * `DB_PASSWD`: (default: ``) * [security]: * `INSTALL_LOCK`: (default: `true`) * `SECRET_KEY`: (default: `JPuNRXxX2G`) With these environment variables available, user can easily run the docker image with minor modifications without creating an custom `app.ini`, such as: ```bash $ docker run -d -p 3000:3000 \ -e ROOT_URL=http://dev.example.com \ -e DB_TYPE=mysql \ -e DB_HOST=1.2.3.4:3306 \ -e DB_USER=gitea \ -e DB_PASSWD=Sup3rPassw0rd \ -e SECRET_KEY=Sup3r3ecre7 \ gitea/gitea:latest ``` Signed-off-by: Tao Wang <twang2218@gmail.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:06:43 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16284