Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi arch #14

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions .github/workflows/publish-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,40 @@ jobs:
env:
DOCKER_USERNAME: ${{ secrets.RENKU_DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.RENKU_DOCKER_PASSWORD }}
DOCKER_REPOSITORY: ${{ secrets.RENKU_DOCKER_REPOSITORY }}
with:
flakes-from-devshell: true
flakes: .#csi-rclone-container-layerd
flakes: .#csi-rclone-container-layerd-amd64
script: |
export TAG=$(echo ${GITHUB_REF} |cut -d/ -f3)
nix build .#csi-rclone-container-layerd && ./result | docker load
docker tag csi-rclone:latest renku/csi-rclone:latest
docker tag csi-rclone:latest renku/csi-rclone:${TAG}
echo ${DOCKER_PASSWORD}|docker login -u ${DOCKER_USERNAME} --password-stdin
docker push renku/csi-rclone:latest
docker push renku/csi-rclone:${TAG}
export DOCKER_REPOSITORY=${DOCKER_REPOSITORY:-renku/csi-rclone}

nix build .#csi-rclone-container-layerd-aarch64 && ./result | docker load
docker tag csi-rclone:latest $DOCKER_REPOSITORY:latest-aarch64
docker tag csi-rclone:latest $DOCKER_REPOSITORY:${TAG}-aarch64

nix build .#csi-rclone-container-layerd-amd64 && ./result | docker load
docker tag csi-rclone:latest $DOCKER_REPOSITORY:latest-amd64
docker tag csi-rclone:latest $DOCKER_REPOSITORY:${TAG}-amd64

echo "${DOCKER_PASSWORD}" | docker login -u ${DOCKER_USERNAME} --password-stdin

docker push $DOCKER_REPOSITORY:latest-aarch64
docker push $DOCKER_REPOSITORY:${TAG}-aarch64
docker push $DOCKER_REPOSITORY:latest-amd64
docker push $DOCKER_REPOSITORY:${TAG}-amd64

docker manifest create \
$DOCKER_REPOSITORY:latest \
--amend $DOCKER_REPOSITORY:latest-amd64 \
--amend $DOCKER_REPOSITORY:latest-aarch64
docker manifest create \
$DOCKER_REPOSITORY:${TAG} \
--amend $DOCKER_REPOSITORY:${TAG}-amd64 \
--amend $DOCKER_REPOSITORY:${TAG}-aarch64

docker manifest push $DOCKER_REPOSITORY:latest
docker manifest push $DOCKER_REPOSITORY:${TAG}

- name: Publish chart
env:
Expand Down
6 changes: 4 additions & 2 deletions devenv/nix/containerImage.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{ pkgs, containerPkgs, csiDriverLinux}:
{ pkgs, containerPkgs, csiDriverLinux, architecture}:

pkgs.dockerTools.streamLayeredImage {
name = "csi-rclone";
tag = "latest";
architecture = "amd64";
architecture = architecture;

contents = [
csiDriverLinux
Expand All @@ -14,10 +14,12 @@ pkgs.dockerTools.streamLayeredImage {
containerPkgs.fuse3
containerPkgs.gawk
containerPkgs.rclone
containerPkgs.findutils
];

extraCommands = ''
mkdir -p ./plugin
mkdir -p ./tmp
ln /bin/linux_*/csi-rclone-plugin /bin/csi-rclone-plugin
'';
}
4 changes: 2 additions & 2 deletions devenv/nix/goModule.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs}:
{ pkgs, architecture}:

let
csiDriver = pkgs.buildGoModule {
Expand All @@ -17,7 +17,7 @@ let
doCheck = false; # tests need docker and kind, which nixbld user might not have access to
};

csiDriverLinux = csiDriver.overrideAttrs (old: old // { CGO_ENABLED = 0; GOOS = "linux"; });
csiDriverLinux = csiDriver.overrideAttrs (old: old // { CGO_ENABLED = 0; GOOS = "linux"; GOARCH=architecture; });
in
{
inherit csiDriver csiDriverLinux ;
Expand Down
4 changes: 2 additions & 2 deletions devenv/nix/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let

text = ''
echo "Building container image"
nix build .#csi-rclone-container-layerd && ./result | docker load
nix build .#csi-rclone-container-layerd-amd64 && ./result | docker load

echo "Loading container image into kind"
kind load docker-image csi-rclone:latest --name csi-rclone-k8s
Expand All @@ -67,7 +67,7 @@ let

text = ''
echo "Building container image"
nix build .#csi-rclone-container-layerd && ./result | docker load
nix build .#csi-rclone-container-layerd-amd64 && ./result | docker load

echo "Loading container image into kind"
kind load docker-image csi-rclone:latest --name csi-rclone-k8s
Expand Down
37 changes: 28 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,44 @@
outputs = { self, nixpkgs, flake-utils}:
flake-utils.lib.eachDefaultSystem (system:
let
# Import pkgs (for your platform) and containerPkgs (x86_64-linux) for crosscompile on MacOS
# Import pkgs (for your platform) and containerPkgs (x86_64-linux/aarch64-linux) for crosscompile on MacOS
pkgs = nixpkgs.legacyPackages.${system};
containerPkgs = import nixpkgs { localSystem = system; crossSystem = "x86_64-linux"; };
containerPkgsAmd64 = import nixpkgs { localSystem = system; crossSystem = "x86_64-linux"; };
containerPkgsAArch64 = import nixpkgs { localSystem = system; crossSystem = "aarch64-linux"; };

goModule = import ./devenv/nix/goModule.nix { inherit pkgs; };
inherit (goModule) csiDriver csiDriverLinux;
goModuleAmd64 = import ./devenv/nix/goModule.nix { inherit pkgs; architecture = "amd64";};
csiDriverAmd64 = goModuleAmd64.csiDriver;
csiDriverLinuxAmd64 = goModuleAmd64.csiDriverLinux;

goModuleAarch64 = import ./devenv/nix/goModule.nix { inherit pkgs; architecture = "arm64";};
csiDriverAarch64 = goModuleAarch64.csiDriver;
csiDriverLinuxAarch64 = goModuleAarch64.csiDriverLinux;

dockerLayerdImageAmd64 = import ./devenv/nix/containerImage.nix {
inherit pkgs;
csiDriverLinux = csiDriverLinuxAmd64;
containerPkgs = containerPkgsAmd64;
architecture = "amd64";
};
dockerLayerdImageAArch64 = import ./devenv/nix/containerImage.nix {
inherit pkgs;
csiDriverLinux = csiDriverLinuxAarch64;
containerPkgs = containerPkgsAArch64;
architecture = "aarch64";
};

dockerLayerdImage = import ./devenv/nix/containerImage.nix { inherit pkgs containerPkgs csiDriverLinux; };

scripts = import ./devenv/nix/scripts.nix { inherit pkgs; };
inherit (scripts) initKindCluster deleteKindCluster getKindKubeconfig localDeployScript reloadScript;

in
{
devShells.default = import ./devenv/nix/shell.nix { inherit pkgs; };

packages.csi-rclone-binary = csiDriver;
packages.csi-rclone-binary-linux = csiDriverLinux;
packages.csi-rclone-container-layerd = dockerLayerdImage;
packages.csi-rclone-binary-amd64 = csiDriverAmd64;
packages.csi-rclone-binary-linux-amd64 = csiDriverLinuxAmd64;
packages.csi-rclone-binary-linux-aarch64 = csiDriverLinuxAarch64;
packages.csi-rclone-container-layerd-amd64 = dockerLayerdImageAmd64;
packages.csi-rclone-container-layerd-aarch64 = dockerLayerdImageAArch64;
packages.deployToKind = localDeployScript;
packages.reload = reloadScript;
packages.initKind = initKindCluster;
Expand Down
Loading