### ### Build Variables ### FROM localhost/debian:latest # deploy options # -p (port) and -v (volume) both go host:container LABEL deployopts="\ -p 9081:80 \ -p 9022:22 \ -v /srv/vol/gitea/git:/vol/git \ -v /srv/vol/gitea/data:/vol/data" # Build variables # uid that the files owner user should have ARG FILESUID=5000 # Container Variables # database name and user ENV DBUSER=gtadmin ENV DBNAME=gitea ### ### General Setup ### # install packages we want RUN apt update -y && apt install -y postgresql postgresql-doc git # put database variables in /etc/environment so anyone can access them # also autodetect versions of postgres and gitea and put them in /etc/environment as well RUN echo "DBUSER=$DBUSER" >> /etc/environment && \ echo "DBNAME=$DBNAME" >> /etc/environment && \ echo "PSQLV=$(psql -V | cut -d ' ' -f 3 | cut -d '.' -f 1)" >> /etc/environment && \ echo "GITEAV=$(wget -q -O - https://dl.gitea.io/gitea/ | grep -m 1 'Current Release' \ | perl -pe 's/.*Current Release ([\d.]+).*/\1/')" >> /etc/environment # create gitea user with file owner UID RUN addgroup --gid $FILESUID gitea && \ adduser gitea --ingroup gitea --uid $FILESUID --disabled-password --gecos "Gitea Server" --shell /usr/sbin/nologin --home /var/lib/gitea # copy our custom scripts COPY assets/bin/ /usr/local/bin/ ### ### PostgreSQL ### ### # configure PostgreSQL access COPY --chown=postgres:postgres assets/pg_hba.conf /etc/postgresql/${PSQLV:?}/main/pg_hba.conf ### ### Gitea ### # dowload gitea RUN wget https://dl.gitea.io/gitea/${GITEAV:?}/gitea-${GITEAV:?}-linux-amd64 && \ mv gitea-${GITEAV:?}-linux-amd64 /usr/local/bin/gitea && \ chmod +x /usr/local/bin/gitea # make directories gitea needs RUN mkdir -p /var/lib/gitea/ && \ cd /var/lib/gitea/ && \ mkdir custom data log && \ chown -R gitea:gitea /var/lib/gitea/ && \ chmod -R 750 /var/lib/gitea/ # copy gitea config template COPY assets/app.ini.esh /etc/gitea/ # template config file RUN cd /etc/gitea/ && \ esh app.ini.esh > app.ini && \ rm app.ini.esh && \ chmod -R +r /etc/gitea/ COPY assets/gitea.service /etc/systemd/system/ ### ### Crontab ### COPY assets/crontab /root/ RUN crontab -u gitea /root/crontab ### ### Bugfix ### # bugfix for cron COPY bugfix/cronfix /root/ RUN chmod +x /root/cronfix && /root/cronfix