docker: gitea: add Gitea

This commit is contained in:
Magic_RB 2021-01-11 21:30:37 +01:00
parent e3e183696f
commit bfb5972fa0
3 changed files with 79 additions and 1 deletions

77
docker/gitea/default.nix Normal file
View file

@ -0,0 +1,77 @@
{ pkgs, system, nixpkgs, ... }:
let
# pkgs = (import nixpkgs { inherit system; }).pkgsMusl;
init = let
defaults = {
uid = builtins.toString 5001;
gid = builtins.toString 5001;
user = "gitea";
data = "/data/gitea";
};
custom = rec {
gitea = pkgs.gitea.override {
inherit openssh git;
pamSupport = false;
};
openssh = pkgs.openssh.override {
withKerberos = false; withFIDO = false;
};
git = pkgs.git.override {
inherit openssh;
perlSupport = false;
nlsSupport = false;
withManual = false;
guiSupport = false;
pythonSupport = false;
withpcre2 = false;
sendEmailSupport = false;
};
};
in
with pkgs; with defaults; pkgs.writeShellScriptBin "init" ''
if [[ $(${busybox}/bin/id -u) = 0 ]] ; then
${busybox}/bin/cat << EOF
### Gitea Nix Image Manual
##
## USER_UID ? ${uid} - default user id
## USER_GID ? ${gid} - default group id
## for other options please look at https://docs.gitea.io/en-us/install-with-docker/#environment-variables
### Recommended volumes (many directories which exist in normal Docker containers, do not exist in this one)
##
## - ${data} - Gitea base data folder
EOF
export _user_uid="''${USER_UID:-${uid}}" \
_user_uid="''${USER_UID:-${uid}}" \
_user="''${USER:-${user}}"
${busybox}/bin/cat << EOF
### Starting with options:
## USER_UID = "$_user_uid"
## USER_GID = "$_user_uid"
EOF
echo "gitea:x:$_uid:$_postgres_gid:Gitea:${data}:${bash}/bin/bash" > /etc/passwd
echo "gitea:x:$_gid:" > /etc/group
${busybox}/bin/mkdir -p ${data}
exec ${busybox}/bin/su -p gitea -c "$0"
else
exec ${custom.gitea}/bin/gitea $@
fi
'';
in
pkgs.dockerTools.buildLayeredImage {
name = "gitea";
tag = "latest";
config = {
Cmd = [ "${init}/bin/init" ];
};
}

View file

@ -34,6 +34,7 @@
dockerImages = lib.dockerImages ./docker [
"klippy-moonraker"
"postgresql"
"gitea"
"csi-driver-nfs"
];
pkgs = lib.pkgsWithFlakes flakes;

View file

@ -7,7 +7,7 @@ with pkgs.lib; {
self
);
dockerImages = path: modules: genAttrs modules (module:
import (path + "/${module}") ({ inherit pkgs; } // inputs)
import (path + "/${module}") ({ inherit pkgs system; } // inputs)
);
pkgsWithFlakes = flakes: import nixpkgs
{