2019-10-14 10:17:40 +03:00
|
|
|
{ pkgs, urbit, pill }:
|
2019-10-03 21:19:07 +03:00
|
|
|
|
2019-10-04 21:29:18 +03:00
|
|
|
let
|
2019-10-14 10:17:40 +03:00
|
|
|
|
2019-10-04 21:29:18 +03:00
|
|
|
name = urbit.meta.name;
|
|
|
|
debug = urbit.meta.debug;
|
2019-10-14 10:17:40 +03:00
|
|
|
exe = ''${urbit.meta.exe} "$@"'';
|
|
|
|
|
|
|
|
coredump = ''
|
|
|
|
ulimit -c unlimited
|
2019-10-04 21:29:18 +03:00
|
|
|
|
2019-10-14 10:17:40 +03:00
|
|
|
${exe} || \
|
|
|
|
${pkgs.gdb}/bin/gdb -ex "thread apply all bt" -ex "set pagination 0" -batch \
|
|
|
|
${urbit.meta.bin} \
|
|
|
|
/tmp/cores/core*
|
|
|
|
'';
|
2019-10-04 21:29:18 +03:00
|
|
|
|
2019-10-14 10:17:40 +03:00
|
|
|
entrypoint = pkgs.writeScript "entrypoint.sh" ''
|
2019-10-04 21:29:18 +03:00
|
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2019-10-14 10:17:40 +03:00
|
|
|
${pkgs.coreutils}/bin/ln -sf ${pill} /data/urbit.pill
|
2019-10-04 21:29:18 +03:00
|
|
|
|
2019-10-14 10:17:40 +03:00
|
|
|
${if debug then coredump else exe}
|
2019-10-04 21:29:18 +03:00
|
|
|
'';
|
2019-10-14 10:17:40 +03:00
|
|
|
|
2019-10-04 21:29:18 +03:00
|
|
|
in
|
|
|
|
|
2019-10-03 21:19:07 +03:00
|
|
|
pkgs.dockerTools.buildImage {
|
|
|
|
inherit name;
|
|
|
|
|
|
|
|
runAsRoot = ''
|
|
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
export PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PATH
|
|
|
|
|
|
|
|
${pkgs.dockerTools.shadowSetup}
|
|
|
|
|
2019-10-04 21:29:18 +03:00
|
|
|
mkdir -p /data /tmp/cores
|
2019-10-03 21:19:07 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
config = {
|
2019-10-14 10:17:40 +03:00
|
|
|
Entrypoint = entrypoint;
|
2019-10-03 21:19:07 +03:00
|
|
|
|
|
|
|
WorkingDir = "/data";
|
|
|
|
|
|
|
|
Volumes = {
|
|
|
|
"/data" = {};
|
|
|
|
"/tmp" = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
ExposedPorts = {
|
|
|
|
"80/tcp" = {};
|
|
|
|
"443/tcp" = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|