mirror of
https://gitlab.com/TECHNOFAB/coder-templates.git
synced 2025-12-12 02:00:11 +01:00
ci: add multi arch image builds
This commit is contained in:
parent
c2a5f47341
commit
8f931d2f43
1 changed files with 25 additions and 7 deletions
32
flake.nix
32
flake.nix
|
|
@ -22,6 +22,7 @@
|
||||||
inputs',
|
inputs',
|
||||||
pkgs,
|
pkgs,
|
||||||
system,
|
system,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
_module.args.pkgs = import nixpkgs {
|
_module.args.pkgs = import nixpkgs {
|
||||||
|
|
@ -37,6 +38,7 @@
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.opentofu
|
pkgs.opentofu
|
||||||
pkgs.coder
|
pkgs.coder
|
||||||
|
pkgs.buildah
|
||||||
];
|
];
|
||||||
|
|
||||||
pre-commit.hooks = {
|
pre-commit.hooks = {
|
||||||
|
|
@ -85,7 +87,9 @@
|
||||||
|
|
||||||
ci = {
|
ci = {
|
||||||
stages = ["build" "upload"];
|
stages = ["build" "upload"];
|
||||||
jobs = {
|
jobs = let
|
||||||
|
SYSTEMS = ["aarch64-linux" "x86_64-linux"];
|
||||||
|
in {
|
||||||
"build" = {
|
"build" = {
|
||||||
stage = "build";
|
stage = "build";
|
||||||
parallel.matrix = [
|
parallel.matrix = [
|
||||||
|
|
@ -101,23 +105,37 @@
|
||||||
};
|
};
|
||||||
"build:image" = {
|
"build:image" = {
|
||||||
stage = "build";
|
stage = "build";
|
||||||
|
parallel.matrix = [
|
||||||
|
{SYSTEM = SYSTEMS;}
|
||||||
|
];
|
||||||
script = [
|
script = [
|
||||||
"nix build .#nix-coder-image"
|
"nix build .#nix-coder-image --system $SYSTEM"
|
||||||
];
|
];
|
||||||
after_script = [
|
after_script = [
|
||||||
"install -D result dist/nix-coder-image.tar.gz"
|
"install -D result dist/nix-coder-image_\${SYSTEM}.tar.gz"
|
||||||
];
|
];
|
||||||
artifacts.paths = ["dist/"];
|
artifacts.paths = ["dist/"];
|
||||||
};
|
};
|
||||||
"upload" = {
|
"upload" = {
|
||||||
stage = "upload";
|
stage = "upload";
|
||||||
deps = [pkgs.skopeo];
|
deps = [pkgs.buildah];
|
||||||
needs = ["build:image"];
|
needs = ["build:image"];
|
||||||
|
before_script = [
|
||||||
|
''export REGISTRY_AUTH_FILE=''${HOME}/auth.json''
|
||||||
|
''echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY''
|
||||||
|
''
|
||||||
|
mkdir -p /etc/containers &&
|
||||||
|
echo '{"default":[{"type":"insecureAcceptAnything"}]}' > /etc/containers/policy.json
|
||||||
|
''
|
||||||
|
];
|
||||||
script = [
|
script = [
|
||||||
''
|
''
|
||||||
skopeo --insecure-policy copy --dest-creds "''${CI_REGISTRY_USER}:''${CI_REGISTRY_PASSWORD}" --tmpdir /tmp \
|
buildah manifest create localhost/nix-coder-image \
|
||||||
"docker-archive:dist/nix-coder-image.tar.gz" \
|
${lib.concatStrings (builtins.map (sys: "docker-archive:dist/nix-coder-image_${sys} \\") SYSTEMS)}
|
||||||
"docker://''${CI_REGISTRY_IMAGE}/nix-coder-image:''${CI_COMMIT_SHORT_SHA}"
|
''
|
||||||
|
''
|
||||||
|
buildah manifest push --all localhost/nix-coder-image \
|
||||||
|
docker://''${CI_REGISTRY_IMAGE}/nix-coder-image:$CI_COMMIT_SHORT_SHA
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue