Add environment variable support for Docker image #2201
No reviewers
Labels
No Label
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
frontport/done
frontport/main
good first issue
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
performance/cpu
performance/memory
performance/speed
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
reviewed/duplicate
reviewed/fixed
reviewed/invalid
reviewed/not-a-bug
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
No Milestone
No project
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: lunny/gitea#2201
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "docker-variables"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
gettext
dependencies as we needenvsubst
command;cp
the template if noapp.ini
exist, it will substitude the envvars and generate the newapp.ini
;/docker/etc/templates/app.ini
a template contains environmentvariables;
The following environment variable can be set:
APP_NAME
: (default:Gitea: Git with a cup of tea
)APP_MODE
: (default:dev
)SSH_DOMAIN
: (default:localhost
)HTTP_PORT
: (default:3000
)ROOT_URL
: (default: '')DISABLE_SSH
: (default:false
)SSH_PORT
: (default:22
)DB_TYPE
: (default:sqlite3
)DB_HOST
: (default:localhost:3306
)DB_NAME
: (default:gitea
)DB_USER
: (default:root
)DB_PASSWD
: (default: ``)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:Signed-off-by: Tao Wang twang2218@gmail.com
This need rebase. This is good to be configurated by env var but
We shoudn't use a default SECRET_KEY.
I think that we shoud only set INSTALL_LOCK to true only if SECRET_KEY set by user otherwise we should display the /install page.
@sapk Good point, I updated the PR, only set
INSTALL_LOCK
totrue
ifSECRET_KEY
is not empty, andINSTALL_LOCK
is empty. And the defaultSECRET_KEY
is removed.Thanks for this PR!
Small typo:
environment
@ -15,1 +15,3 @@
cp /etc/templates/app.ini /data/gitea/conf/app.ini
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
# INSTALL_LOCK is empty
This is pretty obvious from the instruction itself.
Maybe a more useful comment would by why it's needed to set
INSTALL_LOCK
totrue
.@ -15,1 +15,3 @@
cp /etc/templates/app.ini /data/gitea/conf/app.ini
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
# INSTALL_LOCK is empty
This is a good question, why it's needed?
It was obviously that we alway go through the installation process to setup the
SECRET_KEY
. However, why we have to?I didn't find any document clear the relationship between
INSTALL_LOCK
andSECRET_KEY
, so I read the code, and I found theSECRET_KEY
will be randomly generated ONLY during the installation:2c3a229a3c/routers/install.go (L315-L320)
Otherwise, it will try to find the user setting
SECRET_KEY
first, and if user is not providing the value, it will use the default string!#@FDEWREWR&*(
, which is not safe and should be random generated.ced50e0ec1/modules/setting/setting.go (L813)
ping @sapk and @lunny , could you tell me why the default value for the
SECRET_KEY
is a static value, instead of a randomly generated key?I read the issue https://github.com/go-gitea/gitea/pull/455 , I'm still not clear. I think the
SECRET_KEY
should always be generated if the value is not provided by the user, the static default string should be avoided in this case.fixed.
@ -15,1 +15,3 @@
cp /etc/templates/app.ini /data/gitea/conf/app.ini
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
# INSTALL_LOCK is empty
@twang2218 It should be.
LGTM
LGTM
Codecov Report
Continue to review full report at Codecov.