Skip to content

Commit

Permalink
fix docker pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Dec 10, 2020
1 parent d4c0cf9 commit 9099f25
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/run-nomad-job.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ name, lib, json, dockerImages, writeShellScriptBin, vault-bin, awscli
, coreutils, jq, nomad, consul, nixFlakes, curl, gnugrep, gitMinimal }:
, coreutils, jq, nomad, consul, nixFlakes, docker, curl, gnugrep, gitMinimal }:
let
pushImage = imageId: image:
let
Expand All @@ -14,10 +14,10 @@ let
if curl -s "${url}" | grep "${image.imageTag}" &> /dev/null; then
echo "Image already exists in registry"
else
nix-store -r ${
storePath="$(nix-store -r ${
builtins.unsafeDiscardStringContext image.drvPath
} -o .docker-image
docker load -i ./.docker-image
})"
docker load -i "$storePath"
docker push ${image.imageName}:${image.imageTag}
fi
'';
Expand All @@ -35,6 +35,7 @@ in writeShellScriptBin "nomad-run" ''
curl
gnugrep
gitMinimal
docker
]
}"
echo "running job: ${json}"
Expand Down Expand Up @@ -95,6 +96,8 @@ in writeShellScriptBin "nomad-run" ''
${lib.optionalString ((builtins.length pushImages) > 0) ''
dockerPassword="$(vault kv get -field value kv/nomad-cluster/docker-developer-password)"
domain="$(nix eval ".#clusters.$BITTE_CLUSTER.proto.config.cluster.domain" --raw)"
echo "$dockerPassword" | docker login "docker.$domain" -u developer --password-stdin
''}
${builtins.concatStringsSep "\n" pushImages}
Expand Down

0 comments on commit 9099f25

Please sign in to comment.