2021-04-02 01:39:01 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
{ pkgs, ... }:
|
|
|
|
let
|
|
|
|
origImageArgs = {
|
|
|
|
imageName = "octobus/heptapod";
|
2022-04-04 13:53:06 +00:00
|
|
|
imageDigest = "sha256:af6a7f47a15410c521a0d620377b98fa6f5715d6f091ea39d7e332146d20786c";
|
|
|
|
sha256 = "sha256:1gdi9q02g2a5y2vmpxray4l8rq3yapqpdbg0fg7xxk9f99ysng7j";
|
2021-04-02 01:39:01 +00:00
|
|
|
finalImageName = "octobus/heptapod";
|
2022-04-04 13:53:06 +00:00
|
|
|
finalImageTag = "0.30.1";
|
2021-04-02 01:39:01 +00:00
|
|
|
};
|
|
|
|
origImage = pkgs.dockerTools.pullImage origImageArgs;
|
|
|
|
|
|
|
|
name = origImageArgs.imageName;
|
|
|
|
tag = "${origImageArgs.finalImageTag}-lukegb";
|
|
|
|
in pkgs.dockerTools.buildImage rec {
|
|
|
|
inherit name tag;
|
|
|
|
fromImage = origImage;
|
|
|
|
fromImageName = origImageArgs.finalImageName;
|
|
|
|
fromImageTag = origImageArgs.finalImageTag;
|
2022-03-24 22:20:56 +00:00
|
|
|
diskSize = 9216;
|
2021-04-02 01:39:01 +00:00
|
|
|
runAsRoot = ''
|
|
|
|
#!{pkgs.runtimeShell}
|
2022-03-13 00:24:57 +00:00
|
|
|
cat <<"EOF" >/sshd_ca.pub
|
|
|
|
${builtins.readFile ../../../ops/secrets/client-ca.pub}
|
|
|
|
EOF
|
2021-04-02 01:39:01 +00:00
|
|
|
cat <<"EOF" >/assets/wrapper_wrapper
|
2021-04-02 02:08:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
/usr/bin/id hg || /usr/sbin/useradd -g $(id -u git) -u $(id -g git) -o -d /var/opt/gitlab -p "*" hg
|
|
|
|
/usr/bin/grep "AllowUsers git hg" /assets/sshd_config || /bin/sed -i "s/AllowUsers git/AllowUsers git hg/" /assets/sshd_config
|
2022-03-13 00:24:57 +00:00
|
|
|
/usr/bin/cat <<"EOC" >>/assets/sshd_config
|
|
|
|
TrustedUserCAKeys /sshd_ca.pub
|
|
|
|
Match User git
|
|
|
|
AuthorizedPrincipalsCommandUser root
|
|
|
|
AuthorizedPrincipalsCommand /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-authorized-principals-check lukegb lukegb
|
|
|
|
Match User hg
|
|
|
|
AuthorizedPrincipalsCommandUser root
|
|
|
|
AuthorizedPrincipalsCommand /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-authorized-principals-check lukegb lukegb
|
|
|
|
EOC
|
2021-04-02 02:08:40 +00:00
|
|
|
exec /assets/wrapper "$@"
|
2021-04-02 01:39:01 +00:00
|
|
|
EOF
|
|
|
|
chmod ugo=rx /assets/wrapper_wrapper
|
|
|
|
'';
|
|
|
|
config.Cmd = ["/assets/wrapper_wrapper"];
|
|
|
|
} // {
|
|
|
|
meta = { inherit name tag; };
|
|
|
|
}
|