~b12f/pub-solar-os

47ffd26add80031fa5f0cbe28d131b10bea15f2d — Benjamin Bädorf 2 years ago b751593 + 87d7697 main
Merge pull request 'Add docker drone runner wrapper' (#81) from feature/drone-docker-runner into main

Reviewed-on: https://git.b12f.io/pub-solar/os/pulls/81
Reviewed-by: teutat3s <teutates@mailbox.org>
2 files changed, 33 insertions(+), 0 deletions(-)

M pkgs/default.nix
A pkgs/drone-docker-runner.nix
M pkgs/default.nix => pkgs/default.nix +1 -0
@@ 16,6 16,7 @@ with final; {
  toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final);
  uhk-agent = import ./uhk-agent.nix final;
  wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);
  drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final);

  # ps-fixes
  ps-signal-desktop = writeShellScriptBin "signal-desktop" (import ./ps-signal-desktop.nix final);

A pkgs/drone-docker-runner.nix => pkgs/drone-docker-runner.nix +32 -0
@@ 0,0 1,32 @@
self: with self; ''
  case $1 in
    start)
      ${self.docker}/bin/docker run --detach \
        --volume=/var/run/docker.sock:/var/run/docker.sock \
        --env=DRONE_RPC_PROTO=$DRONE_RPC_PROTO \
        --env=DRONE_RPC_HOST=$DRONE_RPC_HOST \
        --env=DRONE_RPC_SECRET=$(${self.libsecret}/bin/secret-tool lookup drone rpc-secret) \
        --env=DRONE_RUNNER_CAPACITY=4 \
        --env=DRONE_RUNNER_NAME=$(${self.inetutils}/bin/hostname) \
        --publish=3000:3000 \
        --restart=always \
        --name=drone-runner \
        drone/drone-runner-docker:1
      ;;

    stop)
      ${self.docker}/bin/docker stop drone-runner
      ${self.docker}/bin/docker rm drone-runner
      ;;

    logs)
      ${self.docker}/bin/docker logs drone-runner
      ;;

    *)
      echo "Usage: drone-docker-runner <start|stop|logs>"
      exit 1;
      ;;
  esac

''