Skip to content

Commit 2600cf6

Browse files
committed
Add environment variable support for Docker image
* 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; Signed-off-by: Tao Wang <[email protected]>
1 parent 9a505fa commit 2600cf6

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN apk --no-cache add \
1313
s6 \
1414
curl \
1515
openssh \
16+
gettext \
1617
tzdata
1718
RUN addgroup \
1819
-S -g 1000 \

Dockerfile.aarch64

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ RUN apk --no-cache add \
1212
s6 \
1313
curl \
1414
openssh \
15+
gettext \
1516
tzdata
1617
RUN addgroup \
1718
-S -g 1000 \

Dockerfile.rpi

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN apk --no-cache add \
1313
s6 \
1414
curl \
1515
openssh \
16+
gettext \
1617
tzdata
1718
RUN addgroup \
1819
-S -g 1000 \

docker/etc/s6/gitea/setup

+23-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,29 @@ fi
1212

1313
if [ ! -f /data/gitea/conf/app.ini ]; then
1414
mkdir -p /data/gitea/conf
15-
cp /etc/templates/app.ini /data/gitea/conf/app.ini
15+
16+
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
17+
# INSTALL_LOCK is empty
18+
if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then
19+
INSTALL_LOCK=true
20+
fi
21+
22+
# Substitude the environment variables in the template
23+
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
24+
APP_MODE=${APP_MODE:-"dev"} \
25+
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
26+
HTTP_PORT=${HTTP_PORT:-"3000"} \
27+
ROOT_URL=${ROOT_URL:-""} \
28+
DISABLE_SSH=${DISABLE_SSH:-"false"} \
29+
SSH_PORT=${SSH_PORT:-"22"} \
30+
DB_TYPE=${DB_TYPE:-"sqlite3"} \
31+
DB_HOST=${DB_HOST:-"localhost:3306"} \
32+
DB_NAME=${DB_NAME:-"gitea"} \
33+
DB_USER=${DB_USER:-"root"} \
34+
DB_PASSWD=${DB_PASSWD:-""} \
35+
INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
36+
SECRET_KEY=${SECRET_KEY:-""} \
37+
envsubst < /etc/templates/app.ini > /data/gitea/conf/app.ini
1638
fi
1739

1840
chown -R git:git /data/gitea /app/gitea /data/git

docker/etc/templates/app.ini

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
[repository]
2+
APP_NAME = $APP_NAME
3+
APP_MODE = $APP_MODE
24
ROOT = /data/git/repositories
35

46
[repository.upload]
57
TEMP_PATH = /data/gitea/uploads
68

79
[server]
810
APP_DATA_PATH = /data/gitea
11+
SSH_DOMAIN = $SSH_DOMAIN
12+
HTTP_PORT = $HTTP_PORT
13+
ROOT_URL = $ROOT_URL
14+
DISABLE_SSH = $DISABLE_SSH
15+
SSH_PORT = $SSH_PORT
916

1017
[database]
11-
DB_TYPE = sqlite3
1218
PATH = /data/gitea/gitea.db
19+
DB_TYPE = $DB_TYPE
20+
HOST = $DB_HOST
21+
NAME = $DB_NAME
22+
USER = $DB_USER
23+
PASSWD = $DB_PASSWD
1324

1425
[session]
1526
PROVIDER_CONFIG = /data/gitea/sessions
@@ -22,3 +33,7 @@ PATH = /data/gitea/attachments
2233

2334
[log]
2435
ROOT_PATH = /data/gitea/log
36+
37+
[security]
38+
INSTALL_LOCK = $INSTALL_LOCK
39+
SECRET_KEY = $SECRET_KEY

0 commit comments

Comments
 (0)