gitlab-ci: add docker-images push

This commit is contained in:
Luke Granger-Brown 2020-10-04 02:34:09 +01:00
parent d0e40e4a6b
commit cb4100412a
2 changed files with 36 additions and 0 deletions

View file

@ -38,3 +38,10 @@ kusakabe:
extends: .deploy
#resource_group: kusakabe
script: './hack/deploy.sh "188.165.197.49" ""'
docker-push:
stage: deploy
tags:
- deployer
script:
- 'bash -c "$(nix-build --no-out-link ./docker-images.nix)"'

29
docker-images.nix Normal file
View file

@ -0,0 +1,29 @@
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0
let
depot = (import ./default.nix {});
pkgs = depot.third_party.nixpkgs;
lib = pkgs.lib;
images = {
"registry.apps.k8s.lukegb.tech/twitterchiver/archiver:latest" = depot.go.twitterchiver.archiver.dockerImage;
};
crane = "${depot.nix.pkgs.crane}/bin/crane";
decompress = drv: pkgs.runCommandNoCC "docker-image" {} ''
${pkgs.gzip}/bin/gunzip -c ${drv} > $out
'';
pushCommands = lib.mapAttrsToList (name: value: ''
${crane} push ${decompress value} ${name}
'') images;
authCommands = lib.mapAttrsToList (name: value: ''
${crane} auth login ${name} -u "${value.user}" -p "${value.password}"
'') depot.ops.secrets.deployer.dockerRegistryAuth;
in
pkgs.writeShellScript "push-images" ''
${lib.concatStringsSep "\n" authCommands}
${lib.concatStringsSep "\n" pushCommands}
''