mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-25 07:52:59 +03:00
build: simplify image build interface
This removes the baked in codedump inspection and wrapper scripts in favour of downstream tooling overriding this as necessary by using FROM <image> in their respective dockerfile.
This commit is contained in:
parent
3210acd4de
commit
4813d9829b
@ -2,33 +2,18 @@
|
||||
|
||||
let
|
||||
|
||||
name = urbit.meta.name;
|
||||
debug = urbit.meta.debug;
|
||||
exe = ''${urbit.meta.exe} "$@"'';
|
||||
|
||||
coredump = ''
|
||||
ulimit -c unlimited
|
||||
|
||||
${exe} || \
|
||||
${pkgs.gdb}/bin/gdb -ex "thread apply all bt" -ex "set pagination 0" -batch \
|
||||
${urbit.meta.bin} \
|
||||
/tmp/cores/core*
|
||||
'';
|
||||
|
||||
entrypoint = pkgs.writeScript "entrypoint.sh" ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
${pkgs.coreutils}/bin/ln -sf ${pill} /data/urbit.pill
|
||||
|
||||
${if debug then coredump else exe}
|
||||
${urbit.meta.exe} "$@"
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
pkgs.dockerTools.buildImage {
|
||||
inherit name;
|
||||
name = urbit.meta.name;
|
||||
|
||||
runAsRoot = ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
@ -39,17 +24,21 @@ pkgs.dockerTools.buildImage {
|
||||
|
||||
${pkgs.dockerTools.shadowSetup}
|
||||
|
||||
mkdir -p /data /tmp/cores
|
||||
mkdir -p /bin /share /data /tmp
|
||||
|
||||
${pkgs.coreutils}/bin/ln -sf ${pill} /share/urbit.pill
|
||||
${pkgs.coreutils}/bin/ln -sf ${entrypoint} /bin/urbit
|
||||
'';
|
||||
|
||||
config = {
|
||||
Entrypoint = entrypoint;
|
||||
Entrypoint = [ "urbit" ];
|
||||
|
||||
WorkingDir = "/data";
|
||||
|
||||
Env = [ "PATH=/bin" ];
|
||||
|
||||
Volumes = {
|
||||
"/data" = {};
|
||||
"/tmp" = {};
|
||||
};
|
||||
|
||||
ExposedPorts = {
|
||||
|
@ -12,8 +12,8 @@ let
|
||||
meta = rec {
|
||||
inherit debug;
|
||||
bin = "${urbit}/bin/${name}";
|
||||
flags = if debug then "-g" else "";
|
||||
exe = "${meta.bin} ${meta.flags}";
|
||||
flags = if debug then [ "-g" ] else [];
|
||||
exe = ''${meta.bin} ${pkgs.lib.strings.concatStringsSep " " meta.flags}'';
|
||||
};
|
||||
|
||||
deps =
|
||||
|
17
sh/image
17
sh/image
@ -6,13 +6,6 @@ say() {
|
||||
echo "$1" >&2
|
||||
}
|
||||
|
||||
git_sha="$(git rev-parse HEAD)"
|
||||
git_sha="${git_sha:0:8}"
|
||||
|
||||
git_branch="$(git branch --show-current)"
|
||||
|
||||
git_tag="${git_branch}-${git_sha}"
|
||||
|
||||
say "Building nix/ops/image..."
|
||||
nix_out="$(nix-build nix/ops -A image --no-out-link "$@")"
|
||||
|
||||
@ -20,11 +13,5 @@ say "Loading $nix_out into Docker..."
|
||||
nix_name="$(docker load --quiet --input $nix_out)"
|
||||
nix_name="${nix_name#Loaded image: }"
|
||||
|
||||
say "Re-tagging with git metadata..."
|
||||
image_repo="$(docker images $nix_name --format '{{.Repository}}')"
|
||||
image_name="${image_repo}:${git_tag}"
|
||||
docker tag $nix_name $image_name
|
||||
|
||||
# Output only the new tag on stdout for subsequent pipes/tooling.
|
||||
say $nix_name
|
||||
echo $image_name
|
||||
# Output only the tag on stdout for subsequent pipes/tooling.
|
||||
echo $nix_name
|
||||
|
Loading…
Reference in New Issue
Block a user