### ### 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 /tank/files/git:/vol/git \ -v /tank/files/db/gitea:/vol/db" # make sure mount directories exist RUN mkdir -p /vol/git /vol/db # version of postgres ARG psqlv=11 # uid that the files owner user should have ARG FILESUID=5000 # Container Variables # database name and user ENV DBUSER=gtadmin ENV DBNAME=gitea # put environment variables in /etc/environment so we can access them from cron scripts RUN echo "DBUSER=$DBUSER" >> /etc/environment && \ echo "DBNAME=$DBNAME" >> /etc/environment ### ### General Setup ### # install packages we want RUN apt update -y && apt install -y postgresql postgresql-doc git # 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 # 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/master/gitea-master-linux-amd64 && \ mv gitea-master-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 ### # execute command to workaround bug in cron COPY bugfix/cronfix /root/ RUN chmod +x /root/cronfix && /root/cronfix