build_gitea : add support for static build

This commit is contained in:
minoplhy 2023-11-22 21:54:02 +07:00
parent 5e4f4645b5
commit 3ed26639ff
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF
2 changed files with 24 additions and 8 deletions

View File

@ -6,12 +6,13 @@ DESTINATION=~/gitea-binaries/
mkdir -p $DESTINATION mkdir -p $DESTINATION
cd $MAKE_DIR cd $MAKE_DIR
while getopts 'v:g:n:' flag while getopts 'v:g:n:s' flag
do do
case "${flag}" in case "${flag}" in
v) GITEA_GIT_TAG=${OPTARG};; # Gitea Git Tag v) GITEA_GIT_TAG=${OPTARG};; # Gitea Git Tag
g) GO_VERSION=${OPTARG};; # GOLANG Version g) GO_VERSION=${OPTARG};; # GOLANG Version
n) NODEJS_VERSION=${OPTARG};; # NodeJS Version n) NODEJS_VERSION=${OPTARG};; # NodeJS Version
s) BUILD_STATIC="True";; # Build as Static Assets file
esac esac
done done
@ -41,11 +42,14 @@ then
GO_VERSION=1.20.5 GO_VERSION=1.20.5
fi fi
sudo unlink /usr/bin/go if [[ ! "$BUILD_STATIC" == "True" ]]
wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz then
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz sudo unlink /usr/bin/go
export PATH=$PATH:/usr/local/go/bin wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz
sudo ln -s /usr/local/go/bin /usr/bin/go sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
sudo ln -s /usr/local/go/bin /usr/bin/go
fi
# Gitea # Gitea
@ -66,8 +70,19 @@ else
echo -e "GIT_TAG variable not found. will build on "main" branch." echo -e "GIT_TAG variable not found. will build on "main" branch."
fi fi
LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/gitea/\" -X \"code.gitea.io/gitea/modules/setting.CustomConf=/etc/gitea/app.ini\"" TAGS="bindata sqlite sqlite_unlock_notify" GOOS=linux GOARCH=amd64 make build # Sometimes VPS Provider's CPU limitation is dick
mv gitea $DESTINATION/gitea export NODE_MAX_CONCURRENCY=1
export GOMAXPROCS=1
if [[ "$BUILD_STATIC" == "True" ]]
then
mkdir -p $DESTINATION/gitea-static
LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/gitea/\" -X \"code.gitea.io/gitea/modules/setting.CustomConf=/etc/gitea/app.ini\"" TAGS="bindata sqlite sqlite_unlock_notify" GOOS=linux GOARCH=amd64 make frontend
mv $MAKE_DIR/gitea/web_src/* $DESTINATION/gitea-static
else
LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/gitea/\" -X \"code.gitea.io/gitea/modules/setting.CustomConf=/etc/gitea/app.ini\"" TAGS="bindata sqlite sqlite_unlock_notify" GOOS=linux GOARCH=amd64 make build
mv gitea $DESTINATION/gitea
fi
# Cleanup # Cleanup

View File

@ -16,6 +16,7 @@ curl -L https://github.com/minoplhy/scriptbox/raw/main/build_gitea/Linux/build.s
v) GITEA_GIT_TAG=${OPTARG};; # Gitea Git Tag v) GITEA_GIT_TAG=${OPTARG};; # Gitea Git Tag
g) GO_VERSION=${OPTARG};; # GOLANG Version g) GO_VERSION=${OPTARG};; # GOLANG Version
n) NODEJS_VERSION=${OPTARG};; # NodeJS Version n) NODEJS_VERSION=${OPTARG};; # NodeJS Version
s) BUILD_STATIC="True";; # Build as Static Assets file
``` ```
# Known Issues # Known Issues