Skip to content

Commit 1b358e2

Browse files
authored
chore: update kaniko fork for better cache probing (#273)
1 parent 5be0611 commit 1b358e2

File tree

3 files changed

+50
-14
lines changed

3 files changed

+50
-14
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.4
44

55
// There are a few options we need added to Kaniko!
66
// See: https://github.com/GoogleContainerTools/kaniko/compare/main...coder:kaniko:main
7-
replace github.com/GoogleContainerTools/kaniko => github.com/coder/kaniko v0.0.0-20240624091120-7208a49f5b15
7+
replace github.com/GoogleContainerTools/kaniko => github.com/coder/kaniko v0.0.0-20240717115058-0ba2908ca4d3
88

99
// Required to import codersdk due to gvisor dependency.
1010
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
171171
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
172172
github.com/coder/coder/v2 v2.10.1-0.20240704130443-c2d44d16a352 h1:L/EjCuZxs5tOcqqCaASj/nu65TRYEFcTt8qRQfHZXX0=
173173
github.com/coder/coder/v2 v2.10.1-0.20240704130443-c2d44d16a352/go.mod h1:P1KoQSgnKEAG6Mnd3YlGzAophty+yKA9VV48LpfNRvo=
174-
github.com/coder/kaniko v0.0.0-20240624091120-7208a49f5b15 h1:Rne2frxrqtLEQ/v4f/wS550Yp/WXLCRFzDuxg8b9woM=
175-
github.com/coder/kaniko v0.0.0-20240624091120-7208a49f5b15/go.mod h1:YMK7BlxerzLlMwihGxNWUaFoN9LXCij4P+w/8/fNlcM=
174+
github.com/coder/kaniko v0.0.0-20240717115058-0ba2908ca4d3 h1:Q7L6cjKfw3DIyhKIcgCJEmgxnUTBajmMDrHxXvxgBZs=
175+
github.com/coder/kaniko v0.0.0-20240717115058-0ba2908ca4d3/go.mod h1:YMK7BlxerzLlMwihGxNWUaFoN9LXCij4P+w/8/fNlcM=
176176
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=
177177
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
178178
github.com/coder/quartz v0.1.0 h1:cLL+0g5l7xTf6ordRnUMMiZtRE8Sq5LxpghS63vEXrQ=

integration/integration_test.go

+47-11
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,13 @@ func TestPushImage(t *testing.T) {
10651065

10661066
srv := createGitServer(t, gitServerOptions{
10671067
files: map[string]string{
1068-
".devcontainer/Dockerfile": fmt.Sprintf("FROM %s\nRUN date --utc > /root/date.txt", testImageAlpine),
1068+
".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
1069+
USER root
1070+
ARG WORKDIR=/
1071+
WORKDIR $WORKDIR
1072+
ENV FOO=bar
1073+
RUN echo $FOO > /root/foo.txt
1074+
RUN date --utc > /root/date.txt`, testImageAlpine),
10691075
".devcontainer/devcontainer.json": `{
10701076
"name": "Test",
10711077
"build": {
@@ -1089,7 +1095,7 @@ func TestPushImage(t *testing.T) {
10891095
envbuilderEnv("CACHE_REPO", testRepo),
10901096
envbuilderEnv("GET_CACHED_IMAGE", "1"),
10911097
}})
1092-
require.ErrorContains(t, err, "error probing build cache: uncached command")
1098+
require.ErrorContains(t, err, "error probing build cache: uncached RUN command")
10931099
// Then: it should fail to build the image and nothing should be pushed
10941100
_, err = remote.Image(ref)
10951101
require.ErrorContains(t, err, "NAME_UNKNOWN", "expected image to not be present before build + push")
@@ -1119,7 +1125,13 @@ func TestPushImage(t *testing.T) {
11191125

11201126
srv := createGitServer(t, gitServerOptions{
11211127
files: map[string]string{
1122-
".devcontainer/Dockerfile": fmt.Sprintf("FROM %s\nRUN date --utc > /root/date.txt", testImageAlpine),
1128+
".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
1129+
USER root
1130+
ARG WORKDIR=/
1131+
WORKDIR $WORKDIR
1132+
ENV FOO=bar
1133+
RUN echo $FOO > /root/foo.txt
1134+
RUN date --utc > /root/date.txt`, testImageAlpine),
11231135
".devcontainer/devcontainer.json": `{
11241136
"name": "Test",
11251137
"build": {
@@ -1143,7 +1155,7 @@ func TestPushImage(t *testing.T) {
11431155
envbuilderEnv("CACHE_REPO", testRepo),
11441156
envbuilderEnv("GET_CACHED_IMAGE", "1"),
11451157
}})
1146-
require.ErrorContains(t, err, "error probing build cache: uncached command")
1158+
require.ErrorContains(t, err, "error probing build cache: uncached RUN command")
11471159
// Then: it should fail to build the image and nothing should be pushed
11481160
_, err = remote.Image(ref)
11491161
require.ErrorContains(t, err, "NAME_UNKNOWN", "expected image to not be present before build + push")
@@ -1232,7 +1244,13 @@ func TestPushImage(t *testing.T) {
12321244

12331245
srv := createGitServer(t, gitServerOptions{
12341246
files: map[string]string{
1235-
".devcontainer/Dockerfile": fmt.Sprintf("FROM %s\nRUN date --utc > /root/date.txt", testImageAlpine),
1247+
".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
1248+
USER root
1249+
ARG WORKDIR=/
1250+
WORKDIR $WORKDIR
1251+
ENV FOO=bar
1252+
RUN echo $FOO > /root/foo.txt
1253+
RUN date --utc > /root/date.txt`, testImageAlpine),
12361254
".devcontainer/devcontainer.json": `{
12371255
"name": "Test",
12381256
"build": {
@@ -1270,7 +1288,7 @@ func TestPushImage(t *testing.T) {
12701288
envbuilderEnv("CACHE_REPO", testRepo),
12711289
envbuilderEnv("GET_CACHED_IMAGE", "1"),
12721290
}})
1273-
require.ErrorContains(t, err, "error probing build cache: uncached command")
1291+
require.ErrorContains(t, err, "error probing build cache: uncached RUN command")
12741292
// Then: it should fail to build the image and nothing should be pushed
12751293
_, err = remote.Image(ref, remoteAuthOpt)
12761294
require.ErrorContains(t, err, "NAME_UNKNOWN", "expected image to not be present before build + push")
@@ -1303,7 +1321,13 @@ func TestPushImage(t *testing.T) {
13031321

13041322
srv := createGitServer(t, gitServerOptions{
13051323
files: map[string]string{
1306-
".devcontainer/Dockerfile": fmt.Sprintf("FROM %s\nRUN date --utc > /root/date.txt", testImageAlpine),
1324+
".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
1325+
USER root
1326+
ARG WORKDIR=/
1327+
WORKDIR $WORKDIR
1328+
ENV FOO=bar
1329+
RUN echo $FOO > /root/foo.txt
1330+
RUN date --utc > /root/date.txt`, testImageAlpine),
13071331
".devcontainer/devcontainer.json": `{
13081332
"name": "Test",
13091333
"build": {
@@ -1332,7 +1356,7 @@ func TestPushImage(t *testing.T) {
13321356
envbuilderEnv("CACHE_REPO", testRepo),
13331357
envbuilderEnv("GET_CACHED_IMAGE", "1"),
13341358
}})
1335-
require.ErrorContains(t, err, "error probing build cache: uncached command")
1359+
require.ErrorContains(t, err, "error probing build cache: uncached RUN command")
13361360
// Then: it should fail to build the image and nothing should be pushed
13371361
_, err = remote.Image(ref, remoteAuthOpt)
13381362
require.ErrorContains(t, err, "NAME_UNKNOWN", "expected image to not be present before build + push")
@@ -1386,7 +1410,7 @@ COPY --from=a /root/date.txt /date.txt`, testImageAlpine, testImageAlpine),
13861410
envbuilderEnv("GET_CACHED_IMAGE", "1"),
13871411
envbuilderEnv("DOCKERFILE_PATH", "Dockerfile"),
13881412
}})
1389-
require.ErrorContains(t, err, "error probing build cache: uncached command")
1413+
require.ErrorContains(t, err, "error probing build cache: uncached RUN command")
13901414
// Then: it should fail to build the image and nothing should be pushed
13911415
_, err = remote.Image(ref)
13921416
require.ErrorContains(t, err, "NAME_UNKNOWN", "expected image to not be present before build + push")
@@ -1422,7 +1446,13 @@ COPY --from=a /root/date.txt /date.txt`, testImageAlpine, testImageAlpine),
14221446

14231447
srv := createGitServer(t, gitServerOptions{
14241448
files: map[string]string{
1425-
".devcontainer/Dockerfile": fmt.Sprintf("FROM %s\nRUN date --utc > /root/date.txt", testImageAlpine),
1449+
".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
1450+
USER root
1451+
ARG WORKDIR=/
1452+
WORKDIR $WORKDIR
1453+
ENV FOO=bar
1454+
RUN echo $FOO > /root/foo.txt
1455+
RUN date --utc > /root/date.txt`, testImageAlpine),
14261456
".devcontainer/devcontainer.json": `{
14271457
"name": "Test",
14281458
"build": {
@@ -1448,7 +1478,13 @@ COPY --from=a /root/date.txt /date.txt`, testImageAlpine, testImageAlpine),
14481478

14491479
srv := createGitServer(t, gitServerOptions{
14501480
files: map[string]string{
1451-
".devcontainer/Dockerfile": fmt.Sprintf("FROM %s\nRUN date --utc > /root/date.txt", testImageAlpine),
1481+
".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
1482+
USER root
1483+
ARG WORKDIR=/
1484+
WORKDIR $WORKDIR
1485+
ENV FOO=bar
1486+
RUN echo $FOO > /root/foo.txt
1487+
RUN date --utc > /root/date.txt`, testImageAlpine),
14521488
".devcontainer/devcontainer.json": `{
14531489
"name": "Test",
14541490
"build": {

0 commit comments

Comments
 (0)