Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 1ed1112

Browse files
authored
feat: added support for specifying arch when building an image (#45)
### **PR Type** Enhancement ___ ### **Description** • Added architecture parameter support to Docker image building functions • Set default architecture to `pkgs.go.GOARCH` for both generic and Go-specific builders • Enhanced `dockerImageFn` and `docker-image` functions with arch configuration • Improved cross-platform Docker image building capabilities ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>generic.nix</strong><dd><code>Add architecture parameter to generic Docker functions</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> lib/generic/generic.nix • Added <code>arch</code> parameter with default value <code>pkgs.go.GOARCH</code> to <br><code>dockerImageFn</code><br> • Updated function calls to pass <code>arch</code> parameter to <br><code>nix2container.buildImage</code><br> • Enhanced <code>docker-image</code> function with <br>architecture support </details> </td> <td><a href="https://github.com/nhost/nixops/pull/45/files#diff-4fd7b531e0557f3d3821654731cc7ed209a62fa21ec7a5d93753481fd58d5340">+4/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>go.nix</strong><dd><code>Add architecture parameter to Go Docker functions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> lib/go/go.nix • Added <code>arch</code> parameter with default value <code>pkgs.go.GOARCH</code> to <br>Go-specific <code>dockerImageFn</code><br> • Updated function signatures and calls to <br>include architecture parameter<br> • Enhanced Go Docker image building <br>with cross-platform support </details> </td> <td><a href="https://github.com/nhost/nixops/pull/45/files#diff-1377128cceefd42b43cd5e407ec11a809c7aaec2d071a1ed0e3232f6dce63fad">+4/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
1 parent 6421c2f commit 1ed1112

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/generic/generic.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ let
88
, copyToRoot ? null
99
, maxLayers ? 100
1010
, config ? { }
11+
, arch ? pkgs.go.GOARCH
1112
}:
1213
nix2containerPkgs.nix2container.buildImage {
13-
inherit name tag created copyToRoot fromImage maxLayers config;
14+
inherit name tag created copyToRoot fromImage maxLayers config arch;
1415
};
1516
in
1617
{
@@ -22,10 +23,11 @@ in
2223
, copyToRoot ? null
2324
, maxLayers ? 100
2425
, config ? { }
26+
, arch ? pkgs.go.GOARCH
2527
}:
2628
pkgs.runCommand "image-as-dir" { } ''
2729
${(dockerImageFn {
28-
inherit name tag created fromImage copyToRoot maxLayers config;
30+
inherit name tag created fromImage copyToRoot maxLayers config arch;
2931
}).copyTo}/bin/copy-to dir:$out
3032
'';
3133
}

lib/go/go.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ let
1717
, package
1818
, buildInputs
1919
, maxLayers
20+
, arch ? pkgs.go.GOARCH
2021
, contents ? [ ]
2122
, config ? { }
2223
}:
2324
nix2containerPkgs.nix2container.buildImage {
24-
inherit name created maxLayers;
25+
inherit name created maxLayers arch;
2526
tag = version;
2627

2728
copyToRoot = pkgs.buildEnv {
@@ -168,12 +169,13 @@ in
168169
, package
169170
, buildInputs
170171
, maxLayers ? 100
172+
, arch ? pkgs.go.GOARCH
171173
, contents ? [ ]
172174
, config ? { }
173175
}:
174176
pkgs.runCommand "image-as-dir" { } ''
175177
${(dockerImageFn {
176-
inherit name version created package buildInputs maxLayers contents config;
178+
inherit name version created package buildInputs maxLayers arch contents config;
177179
}).copyTo}/bin/copy-to dir:$out
178180
'';
179181
}

0 commit comments

Comments
 (0)