Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit ffbc1ef

Browse files
Merge pull request #1938 from ibuildthecloud/build-contet
Add support for multiple build contexts in Dockerfile builds
2 parents c950bc9 + 063071b commit ffbc1ef

File tree

15 files changed

+99
-23
lines changed

15 files changed

+99
-23
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ replace (
1313
require (
1414
cuelang.org/go v0.5.0
1515
github.com/AlecAivazis/survey/v2 v2.3.6
16-
github.com/acorn-io/aml v0.0.0-20230707055340-d9d7a8c927b2
16+
github.com/acorn-io/aml v0.0.0-20230714230100-7aded86d1c3e
1717
github.com/acorn-io/baaah v0.0.0-20230707151126-5d519d272865
1818
github.com/acorn-io/mink v0.0.0-20230523184405-ceaaa366d500
1919
github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY
9292
github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE=
9393
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
9494
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
95-
github.com/acorn-io/aml v0.0.0-20230707055340-d9d7a8c927b2 h1:zx1YhJI+jecZ1nQ3MzFRblMU4KdACUG8DQfd0zB9XvY=
96-
github.com/acorn-io/aml v0.0.0-20230707055340-d9d7a8c927b2/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
95+
github.com/acorn-io/aml v0.0.0-20230714230100-7aded86d1c3e h1:jx4uFAazHUwX2uMeCHNtOFSTXBMPjQtflQOnPjmkhms=
96+
github.com/acorn-io/aml v0.0.0-20230714230100-7aded86d1c3e/go.mod h1:UEx5RRLFjryCEHN2pM59+d8A0mPJ3VAxggJOTzPymwg=
9797
github.com/acorn-io/baaah v0.0.0-20230707151126-5d519d272865 h1:BPPGCEBgPxn7crFFWqLDJUlzdHQ23olFkdUqlXd3KA8=
9898
github.com/acorn-io/baaah v0.0.0-20230707151126-5d519d272865/go.mod h1:LtwaWrYK/VuGptWxeD5Sgl0sgJV1ksicpTzyLilow1U=
9999
github.com/acorn-io/mink v0.0.0-20230523184405-ceaaa366d500 h1:tiM36bM+iMWuW9HM+YlM1GfNDXC7f565z8Be5epO0qM=

integration/build/build_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ func TestBuildDefault(t *testing.T) {
170170
assert.Len(t, image.ImageData.Containers, 1)
171171
}
172172

173+
func TestBuildMulticontext(t *testing.T) {
174+
c := helper.BuilderClient(t, system.DefaultUserNamespace)
175+
image, err := c.AcornImageBuild(helper.GetCTX(t), "./testdata/multicontextdir/Acornfile", &client.AcornImageBuildOptions{
176+
Cwd: "./testdata/multicontextdir",
177+
})
178+
if err != nil {
179+
t.Fatal(err)
180+
}
181+
assert.Len(t, image.ImageData.Containers, 1)
182+
}
183+
173184
func TestMultiArch(t *testing.T) {
174185
helper.StartController(t)
175186
cfg := helper.StartAPI(t)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
containers: {
2+
simple: {
3+
build: {
4+
dockerfile: "Dockerfile"
5+
context: "./files"
6+
additionalContexts: {
7+
"other-context": "./files/subdir"
8+
}
9+
}
10+
}
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM ghcr.io/acorn-io/images-mirror/busybox:latest AS not-default
2+
COPY test.sh /test.sh
3+
COPY --from=other-context /token /
4+
RUN test -f /test.sh && sh /test.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
set -e -x
3+
test -f /token
4+
[ "hi" = "$(cat /token)" ]

pkg/apis/internal.acorn.io/v1/appspec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type AcornBuild struct {
4141

4242
type Build struct {
4343
Context string `json:"context,omitempty"`
44+
AdditionalContexts map[string]string `json:"additionalContexts,omitempty"`
4445
Dockerfile string `json:"dockerfile,omitempty"`
4546
DockerfileContents string `json:"dockerfileContents,omitempty"`
4647
Target string `json:"target,omitempty"`

pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/appdefinition/appdefinition_test.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,35 +1017,39 @@ images: {
10171017
},
10181018
"build": {
10191019
Build: &v1.Build{
1020-
BuildArgs: map[string]string{},
1021-
Context: ".",
1022-
Dockerfile: "Dockerfile",
1020+
BuildArgs: map[string]string{},
1021+
AdditionalContexts: map[string]string{},
1022+
Context: ".",
1023+
Dockerfile: "Dockerfile",
10231024
},
10241025
Sidecars: map[string]v1.ContainerImageBuilderSpec{
10251026
"side": {
10261027
Build: &v1.Build{
1027-
BuildArgs: map[string]string{},
1028-
Context: ".",
1029-
Dockerfile: "Dockerfile",
1028+
BuildArgs: map[string]string{},
1029+
AdditionalContexts: map[string]string{},
1030+
Context: ".",
1031+
Dockerfile: "Dockerfile",
10301032
},
10311033
},
10321034
},
10331035
},
10341036
"buildcontext": {
10351037
Build: &v1.Build{
1036-
BuildArgs: map[string]string{},
1037-
Context: ".",
1038-
Dockerfile: "Dockerfile",
1038+
BuildArgs: map[string]string{},
1039+
AdditionalContexts: map[string]string{},
1040+
Context: ".",
1041+
Dockerfile: "Dockerfile",
10391042
ContextDirs: map[string]string{
10401043
"/var/tmp": "./foo/bar",
10411044
},
10421045
},
10431046
Sidecars: map[string]v1.ContainerImageBuilderSpec{
10441047
"side": {
10451048
Build: &v1.Build{
1046-
BuildArgs: map[string]string{},
1047-
Context: ".",
1048-
Dockerfile: "Dockerfile",
1049+
BuildArgs: map[string]string{},
1050+
AdditionalContexts: map[string]string{},
1051+
Context: ".",
1052+
Dockerfile: "Dockerfile",
10491053
ContextDirs: map[string]string{
10501054
"/var/tmp": "./foo/bar",
10511055
},

0 commit comments

Comments
 (0)