Commit 092a08c2 authored by Bernhard Geier's avatar Bernhard Geier
Browse files

Initial commit

# Gitea-with-PAM Builder
Unfortunately official binaries for Gitea do not support PAM.
This Docker container builds the latest Gitea release with PAM support for Debian based Linux distributions (Debian/Ubuntu/Mint).
## Prerequisites:
Linux machine with installed Docker (Debian/Ubuntu/Mint: `sudo apt-get install`)
## Instructions:
1. Run `./`
2. Wait
3. Get the binary from the directory `./binary/`
EXTRA_TAGS=pam sqlite sqlite_unlock_notify
FROM golang:bullseye
# build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends git build-essential curl jq nodejs npm libpam-dev && \
rm -rf /var/lib/apt/lists/*
# copy build script
# run build script
# do not run as root, but as the calling user
if [ "$(id -u)" -eq 0 ]; then
chown "${HOST_UID}":"${HOST_GID}" /source
chown "${HOST_UID}":"${HOST_GID}" /binary
exec setpriv --reuid="${HOST_UID}" --regid="${HOST_GID}" --clear-groups "$0"
# setpriv does not set $HOME, so we have to do
export HOME=/source
# Fetch source
cd /source
if [ ! -d .git ]; then
git init
git remote add origin "${REPO_URL}"
git remote set-url origin "${REPO_URL}"
git fetch origin || exit 1
# Checkout latest release
GITHUB_REPO=$(echo "${REPO_URL}" | sed 'sX.*/\(.*/.*\)\.gitX\1X')
LATEST_RELEASE=$(curl --silent${GITHUB_REPO}/releases/latest | jq -r .tag_name | sed 's/^\(v[[:digit:]]\.[[:digit:]]*\).*$/\1/')
git checkout release/"${LATEST_RELEASE}" || exit 1
git pull || exit 1
# build
CGO_ENABLED=1 TAGS="bindata netgo osusergo $EXTRA_TAGS" make build || exit 1
# move result to directory "binary"
VERSION=$(/source/gitea --version | sed 's/.*version \([0-9\.]*\) .*/\1/') || exit 1
mv /source/gitea /binary/gitea-${VERSION} || exit 1
echo "Sucessfully build /binary/gitea-${VERSION}"
if [ ! -f ./config.env ]; then
echo "ERROR: config.env is missing."
exit 1
docker build --tag gitea-build-container ./dockerfiles
docker run \
-ti --init \
--volume "$(pwd)/source:/source" \
--volume "$(pwd)/binary:/binary" \
--env HOST_UID="$(id -u)" --env HOST_GID="$(id -g)" \
--env-file ./config.env \
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment