From 3d764b2ee9d728b72a1aaec29dbe41c279cbb14a Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sun, 31 Oct 2021 09:44:31 +0000 Subject: [PATCH 1/2] Use LDFLAGS to set the default locations in docker Too many docker users are caught out by the default location for the app.ini file being environment dependent so that when they docker exec into the container the `gitea` commands do not work properly and require additional `-c` arguments to correctly pick up the configuration. This PR simply builds the default locations into the build. Fix #14468 Reference #17497 Reference #12082 Reference #8941 ... amongst others ... Signed-off-by: Andrew Thornton --- Dockerfile | 2 ++ Dockerfile.rootless | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 69a8cdbec1f5d..4af6b0c0f57a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,8 @@ ENV GOPROXY ${GOPROXY:-direct} ARG GITEA_VERSION ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS "bindata timetzdata $TAGS" +ENV LDFLAGS="$LDFLAGS -X \"code.gitea.io/gitea/modules/setting.CustomPath=/data/gitea\" \ + -X \"code.gitea.io/gitea/modules/setting.AppWorkPath=/app/gitea\"" ARG CGO_EXTRA_CFLAGS #Build deps diff --git a/Dockerfile.rootless b/Dockerfile.rootless index f6430e5f69d45..a28abf10518ff 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -9,6 +9,9 @@ ENV GOPROXY ${GOPROXY:-direct} ARG GITEA_VERSION ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS "bindata timetzdata $TAGS" +ENV LDFLAGS="$LDFLAGS -X \"code.gitea.io/gitea/modules/setting.CustomPath=/var/lib/gitea/custom\" \ + -X \"code.gitea.io/gitea/modules/setting.CustomConf=/etc/gitea/conf.ini\" \ + -X \"code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/gitea\"" ARG CGO_EXTRA_CFLAGS #Build deps From b3df346cc4753844c8f57b220bafa0d0f89736a6 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sun, 28 Nov 2021 19:33:34 +0000 Subject: [PATCH 2/2] fix bug in fhs script Signed-off-by: Andrew Thornton --- contrib/fhs-compliant-script/gitea | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/fhs-compliant-script/gitea b/contrib/fhs-compliant-script/gitea index 019f838f92218..770e80aec46e0 100755 --- a/contrib/fhs-compliant-script/gitea +++ b/contrib/fhs-compliant-script/gitea @@ -37,6 +37,6 @@ if [ -z "$APP_INI_SET" ]; then fi # Provide FHS compliant defaults to -exec -a "$0" GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" "$GITEA" $CONF_ARG "$@" +GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@"