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

Initial commit

parents
# 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 docker.io`)
## Instructions:
1. Run `./start.sh`
2. Wait
3. Get the binary from the directory `./binary/`
REPO_URL=https://github.com/go-gitea/gitea.git
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
COPY build.sh /build.sh
# run build script
ENTRYPOINT /build.sh
#!/bin/bash
# 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"
fi
# 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}"
else
git remote set-url origin "${REPO_URL}"
fi
git fetch origin || exit 1
# Checkout latest release
GITHUB_REPO=$(echo "${REPO_URL}" | sed 'sX.*/\(.*/.*\)\.gitX\1X')
LATEST_RELEASE=$(curl --silent https://api.github.com/repos/${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
echo "Sucessfully build /binary/gitea-${VERSION}"
#!/bin/bash
if [ ! -f ./config.env ]; then
echo "ERROR: config.env is missing."
exit 1
fi
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 \
gitea-build-container
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