Skip to content

Commit 6c4b1f9

Browse files
aledbfclaude
andcommitted
fix(cli)!: build a Dockerfile configuration in one build as the reference does
build and up built a Dockerfile configuration in two steps: the user's Dockerfile with --target <stage> (written as <Dockerfile>.devcontainer.build next to it when its final stage had no name), then, with Features, a second build FROM that image. The file in the workspace failed a read-only workspace and was left behind on an interrupted build, the intermediate image changed layering and the cache, and --push/--output were dropped from the base build. As the reference CLI's buildAndExtendImage, the CLI now writes one combined Dockerfile-with-features (the user's Dockerfile, its final stage named, then the dev_containers_target_stage stage that installs the Features and writes the devcontainer.metadata LABEL, or only the label with no Features) into the Features folder under the cache folder, and runs one build with --target dev_containers_target_stage. The Dockerfile and the build arguments are byte-identical to what v0.90.0 writes and runs for the same configurations. Features and the lockfile are resolved before the build, as in TS. The Go-only behavior carries over to the single build: --secrets-file and --ca-bundle secrets, a sibling <Dockerfile>.dockerignore (#969), the final stage's own devcontainer.metadata entries (#1225), and build contexts. build's hidden --omit-syntax-directive now takes effect. BREAKING CHANGE: up tags a Dockerfile configuration's image with Features vsc-<folder>-<hash>, as the official CLI does, instead of vsc-<folder>-<hash>-features; the build no longer writes <Dockerfile>.devcontainer.build into the workspace. docs/migration.md lists both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a5b7cbe commit 6c4b1f9

13 files changed

Lines changed: 882 additions & 415 deletions

‎docs/DIVERGENCES.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ upstream issue it fixes.
157157
in the build context (upstream #969). This CLI copies the ignore file next to every
158158
Dockerfile it generates (`TestCopyDockerignore`,
159159
`TestBuildAndExtendComposeDockerfileService` in `internal/cli/compose_up_held_test.go`,
160-
and `TestE2E_SiblingDockerignore` in `internal/cli/e2e_fixes_test.go`).
160+
`TestBuildDockerfileKeepsTheSiblingDockerignore`, and `TestE2E_SiblingDockerignore` in `internal/cli/e2e_fixes_test.go`).
161161
- **A `LABEL devcontainer.metadata` in the Dockerfile is kept.** TS builds the image's
162162
metadata label from the base image's label and the configuration and writes it over the
163163
image, so a `LABEL devcontainer.metadata=…` written in the built stage of the user's
164164
Dockerfile is lost (upstream #1225). This CLI merges that stage's entries between the
165165
base image's and the configuration's (`TestStageLabelsDevcontainerMetadata` and
166-
`TestStageLabelsReadsTheNamedStage` in `internal/docker`, `TestDockerfileImageMetadata`
167-
in `internal/cli/build_held_test.go`).
166+
`TestStageLabelsReadsTheNamedStage` in `internal/docker`, `TestBuildDockerfileMetadataLabel`
167+
in `internal/cli/dockerfile_build_held_test.go`).
168168
- **`build --label` applies to a Docker Compose configuration.** `docker compose build`
169169
takes no labels, and TS drops `--label` for a Compose configuration without a word
170170
(upstream #930). This CLI applies the labels with one more build, `FROM <image>`, tagged

‎docs/migration.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ runs the official CLI is unaffected:
101101
matching container.
102102
- Features are staged under `<tmp>/devcontainercli-<user>/container-features/`,
103103
one folder per build, and that folder is kept as the official CLI keeps it.
104+
- A Dockerfile configuration's image is made by one `docker build`, as the
105+
official CLI makes it: the Dockerfile followed by the stage that installs the
106+
Features and writes the `devcontainer.metadata` label, written as
107+
`Dockerfile-with-features` into that Features folder and built with
108+
`--target dev_containers_target_stage`. Earlier releases built the Dockerfile
109+
first, wrote `<Dockerfile>.devcontainer.build` next to it when its last stage had
110+
no name (failing in a read-only workspace), and added the Features in a second
111+
build. `up` of a Dockerfile configuration with Features now tags the image
112+
`vsc-<folder>-<hash>`, not `vsc-<folder>-<hash>-features`; a script that looked
113+
the image up by the old name should use the new one.
104114
- When the workspace is a Git worktree and the configuration sets both
105115
`workspaceMount` and `workspaceFolder`, `up` no longer mounts the main
106116
repository's Git common directory, and `read-configuration` no longer reports

‎docs/parity/parity-matrix.yaml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,34 @@ initial_cases:
17371737
current_status: match
17381738
notes: "Without build.context the context is the Dockerfile's folder (utils.ts getDockerContextPath: parentURI(getDockerfilePath)), not the configuration's: COPY finds the file next to sub/Dockerfile. Go used the configuration's folder and the COPY failed."
17391739

1740+
- id: build.read-only-workspace-dockerfile-success
1741+
lane: runtime
1742+
command: build
1743+
priority: p1
1744+
docker_required: true
1745+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; chmod -R u+w $WORKSPACE 2>/dev/null; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer; printf '%s\\n' 'FROM alpine:3' 'RUN echo ok > /marker' > $WORKSPACE/.devcontainer/Dockerfile; printf '%s' '{\"build\":{\"dockerfile\":\"Dockerfile\"},\"remoteUser\":\"root\"}' > $WORKSPACE/.devcontainer/devcontainer.json; chmod -R a-w $WORKSPACE; echo WORKSPACE=$WORKSPACE"
1746+
ts_cmd: "build --workspace-folder ${WORKSPACE} --image-name parity-${PARITY_CASE_ID}-${PARITY_SIDE}"
1747+
verify_cmd: "cd ${WORKSPACE} && find . | sort; docker history --no-trunc --format '{{.CreatedBy}}' ${IMAGE_NAME}"
1748+
cleanup_cmd: "docker rmi -f parity-${PARITY_CASE_ID}-${PARITY_SIDE} >/dev/null 2>&1; chmod -R u+w /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE} 2>/dev/null; rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; true"
1749+
asserts: [exit_code, stdout_normalized]
1750+
class: build-runtime
1751+
current_status: match
1752+
notes: "TS buildAndExtendImage (singleContainer.ts) builds a Dockerfile configuration in one docker build of Dockerfile-with-features, written into the Features folder under the cache folder: the user's Dockerfile with its final stage named, then FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage with the devcontainer.metadata LABEL, built with --target dev_containers_target_stage. A read-only workspace builds, nothing is written into it, and the image history ends with that LABEL instruction. Go wrote <Dockerfile>.devcontainer.build next to the Dockerfile (failing here with permission denied), built it with --target <stage> and --label devcontainer.metadata=..., and added Features in a second build."
1753+
1754+
- id: up.read-only-workspace-dockerfile-success
1755+
lane: runtime
1756+
command: up
1757+
priority: p1
1758+
docker_required: true
1759+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; chmod -R u+w $WORKSPACE 2>/dev/null; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer; printf '%s\\n' 'FROM alpine:3' 'RUN echo ok > /marker' > $WORKSPACE/.devcontainer/Dockerfile; printf '%s' '{\"build\":{\"dockerfile\":\"Dockerfile\"},\"remoteUser\":\"root\"}' > $WORKSPACE/.devcontainer/devcontainer.json; chmod -R a-w $WORKSPACE; echo WORKSPACE=$WORKSPACE"
1760+
ts_cmd: "up --workspace-folder ${WORKSPACE} --id-label parity.case=${PARITY_CASE_ID}-${PARITY_SIDE}"
1761+
verify_cmd: "cd ${WORKSPACE} && find . | sort; docker exec ${CONTAINER_ID} cat /marker; I=$(docker inspect -f '{{.Image}}' ${CONTAINER_ID}); docker history --no-trunc --format '{{.CreatedBy}}' $I"
1762+
cleanup_cmd: "I=$(docker inspect -f '{{.Image}}' ${CONTAINER_ID} 2>/dev/null); docker rm -f ${CONTAINER_ID} >/dev/null 2>&1; [ -n \"$I\" ] && docker rmi -f $I >/dev/null 2>&1; chmod -R u+w /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE} 2>/dev/null; rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; true"
1763+
asserts: [exit_code, stdout_normalized]
1764+
class: up-runtime
1765+
current_status: match
1766+
notes: "As build.read-only-workspace-dockerfile-success, for up: one build of Dockerfile-with-features from the cache folder, so a read-only workspace starts and holds only what it held. Go failed writing <Dockerfile>.devcontainer.build into the workspace."
1767+
17401768
- id: upgrade.write-lockfile-to-disk-success
17411769
lane: runtime
17421770
command: upgrade

‎internal/cli/build.go‎

Lines changed: 17 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type buildOpts struct {
4343
frozenLockfile bool
4444
secretsFile string
4545
caBundle string
46+
omitSyntaxDirective bool
4647
lockfileExcludeIDs map[string]bool
4748
}
4849

@@ -91,7 +92,7 @@ func newBuildCmd() *cobra.Command {
9192
f.BoolVar(&opts.frozenLockfile, "frozen-lockfile", false, "Ensure lockfile exists and remains unchanged; fail otherwise.")
9293
f.StringVar(&opts.secretsFile, "secrets-file", "", "Path to a JSON file with build secrets ({\"KEY\":\"VALUE\"}); each is passed to BuildKit as a build secret (requires buildx).")
9394
f.StringVar(&opts.caBundle, "ca-bundle", "", caBundleFlagUsage)
94-
f.Bool("omit-syntax-directive", false, "")
95+
f.BoolVar(&opts.omitSyntaxDirective, "omit-syntax-directive", false, "")
9596
cmd.Flags().MarkHidden("skip-feature-auto-mapping")
9697
cmd.Flags().MarkHidden("skip-persisting-customizations-from-features")
9798
cmd.Flags().MarkHidden("experimental-lockfile")
@@ -262,15 +263,6 @@ func buildFlagConflict(opts *buildOpts, useBuildx, compose bool) string {
262263
return ""
263264
}
264265

265-
type dockerfileBuildPrep struct {
266-
Path string
267-
StageName string
268-
Parsed *docker.Dockerfile
269-
cleanup func()
270-
}
271-
272-
func (p *dockerfileBuildPrep) Cleanup() { p.cleanup() }
273-
274266
// copyDockerignore copies a Dockerfile's sibling `<name>.dockerignore` next to a
275267
// renamed/generated build Dockerfile, so BuildKit's per-Dockerfile ignore lookup
276268
// (`<dockerfile>.dockerignore`) still finds the user's rules instead of leaking
@@ -302,139 +294,27 @@ func dockerContextPath(cfg *config.DevContainer) string {
302294
return filepath.Dir(dockerfileConfigPath(cfg))
303295
}
304296

305-
func prepareDockerfileBuild(cfg *config.DevContainer) (*dockerfileBuildPrep, error) {
306-
dockerfilePath := cfg.Dockerfile()
307-
if dockerfilePath == "" {
308-
return nil, fmt.Errorf("no Dockerfile specified")
309-
}
310-
dockerfilePath = dockerfileConfigPath(cfg)
311-
312-
content, err := os.ReadFile(dockerfilePath)
313-
if err != nil {
314-
return nil, fmt.Errorf("read Dockerfile: %w", err)
315-
}
316-
317-
prep := &dockerfileBuildPrep{
318-
Parsed: docker.ExtractDockerfile(string(content)),
319-
cleanup: func() {},
320-
}
321-
322-
if cfg.Build != nil && cfg.Build.Target != "" {
323-
prep.StageName = cfg.Build.Target
324-
} else {
325-
stageName, modified, err := docker.EnsureFinalStageName(string(content), "dev_container_auto_added_stage_label")
326-
if err != nil {
327-
return nil, err
328-
}
329-
prep.StageName = stageName
330-
if modified != "" {
331-
tmpDockerfile := dockerfilePath + ".devcontainer.build"
332-
// mutate-exempt: only the docker build this process starts reads the file, as its owner, and Cleanup removes it
333-
if err := os.WriteFile(tmpDockerfile, []byte(modified), 0644); err != nil {
334-
return nil, fmt.Errorf("write build dockerfile: %w", err)
335-
}
336-
copyDockerignore(dockerfilePath, tmpDockerfile)
337-
prep.cleanup = func() {
338-
os.Remove(tmpDockerfile)
339-
os.Remove(tmpDockerfile + ".dockerignore")
340-
}
341-
dockerfilePath = tmpDockerfile
342-
}
343-
}
344-
345-
prep.Path = dockerfilePath
346-
return prep, nil
347-
}
348-
349-
// mutate-lane: TestParityMatrix (build.dockerfile-multi-image-success,
350-
// build.subfolder-config-success, build.apply-build-options-success,
351-
// build.output-oci-success, build.cache-to-local-success,
352-
// build.platform-supported-dockerfile-success), also run by
297+
// mutate-lane: TestBuildDockerfileBuildsOnce and TestParityMatrix
298+
// (build.dockerfile-multi-image-success, build.subfolder-config-success,
299+
// build.apply-build-options-success, build.output-oci-success,
300+
// build.cache-to-local-success, build.platform-supported-dockerfile-success,
301+
// build.read-only-workspace-dockerfile-success), also run by
353302
// TestE2E_BuildUpExec_Dockerfile, TestE2E_SiblingDockerignore and
354303
// TestE2E_CABundle (an opted-in RUN reads the bundle).
355304
func (r *buildRunner) buildDockerfile(ctx context.Context, cfg *config.DevContainer, loadResult *config.LoadResult, useBuildx bool) ([]string, error) {
356-
logger, dockerClient, engine, opts := r.log, r.docker, r.engine, r.opts
357-
358-
prep, err := prepareDockerfileBuild(cfg)
359-
if err != nil {
360-
return nil, err
361-
}
362-
defer prep.Cleanup()
363-
dockerfilePath := prep.Path
364-
stageName := prep.StageName
365-
366-
findTarget := ""
367-
if cfg.Build != nil {
368-
findTarget = cfg.Build.Target
369-
}
370-
baseImage := docker.FindBaseImage(prep.Parsed, buildArgsFromConfig(cfg), findTarget, buildxPlatformArgs(opts.platform))
371-
logger.Write(fmt.Sprintf("Base image: %s", baseImage), log.LevelInfo)
372-
373-
baseLabels := engine.ImageLabelsEnsuringPresent(ctx, baseImage)
374-
baseMetadata := imagemeta.ReadMetadataFromLabels(baseLabels, logger)
375-
stageMetadata := imagemeta.ReadMetadataFromLabels(prep.Parsed.StageLabels(stageName), logger)
376-
377-
imageNames := imageNamesOr(opts.imageNames, folderImageName(resolvePath(opts.workspaceFolder)))
378-
379-
contextPath := dockerContextPath(cfg)
380-
381-
buildArgs := buildArgsFromConfig(cfg)
382-
383-
allLabels := append(slices.Clone(opts.labels), imageLabelArgs(dockerfileImageMetadata(cfg, baseMetadata, stageMetadata, r.configLabel))...)
384-
385-
baseOutput, basePush := dockerfileBaseExport(opts, cfg)
386-
387-
cacheFrom := cacheFromForDockerfileBuild(opts.cacheFrom, cfg)
388-
authEnv, authCleanup := bridgeBuildAuth(logger, baseImage, imageNames, cacheFrom, opts.cacheTo)
389-
defer authCleanup()
390-
391-
var buildSecrets []string
305+
opts := r.opts
306+
fb := r.featureBuildOptions(cfg, &loadResult.HostSub)
392307
if opts.secretsFile != "" {
393-
secrets, secErr := readSecretsFile(opts.secretsFile)
394-
if secErr != nil {
395-
return nil, fmt.Errorf("read secrets file: %w", secErr)
308+
secrets, err := readSecretsFile(opts.secretsFile)
309+
if err != nil {
310+
return nil, fmt.Errorf("read secrets file: %w", err)
396311
}
397-
buildSecrets = buildxSecrets(secrets, useBuildx, logger)
398-
}
399-
caSecrets := caBundleBuildSecrets(opts.caBundle, useBuildx, logger)
400-
401-
buildOpts := docker.BuildOptions{
402-
Dockerfile: dockerfilePath,
403-
ContextPath: contextPath,
404-
Tags: imageNames,
405-
Target: stageName,
406-
BuildArgs: buildArgs,
407-
CacheFrom: cacheFrom,
408-
Labels: allLabels,
409-
NoCache: opts.noCache,
410-
ExtraArgs: buildOptionsFromConfig(cfg),
411-
UseBuildx: useBuildx,
412-
Platform: opts.platform,
413-
Push: basePush,
414-
Output: baseOutput,
415-
CacheTo: opts.cacheTo,
416-
Env: authEnv,
417-
Secrets: buildSecrets,
418-
FileSecrets: caSecrets,
312+
fb.Secrets = secrets
419313
}
420-
421-
result, err := dockerClient.Build(ctx, buildOpts)
422-
if err != nil {
314+
imageNames := imageNamesOr(opts.imageNames, folderImageName(resolvePath(opts.workspaceFolder)))
315+
if err := buildDockerfileImage(ctx, r.log, r.docker, r.engine, cfg, useBuildx, imageNames, opts.platform, fb); err != nil {
423316
return nil, err
424317
}
425-
if result.ExitCode != 0 {
426-
return nil, fmt.Errorf(msgDockerBuildFailed, result.ExitCode, string(result.Stderr))
427-
}
428-
429-
if dockerClient.ProgressWriter == nil {
430-
logger.Write(string(result.Stderr), log.LevelInfo)
431-
}
432-
433-
if len(cfg.Features) > 0 {
434-
baseImageName := imageNames[0]
435-
return extendImageWithFeatures(ctx, logger, dockerClient, engine, baseImageName, cfg.Features, useBuildx, imageNames, r.featureBuildOptions(cfg, &loadResult.HostSub))
436-
}
437-
438318
return imageNames, nil
439319
}
440320

@@ -595,26 +475,6 @@ func imageNamesOr(names []string, fallback string) []string {
595475
return names
596476
}
597477

598-
// dockerfileImageMetadata is the metadata a Dockerfile build stamps on its
599-
// image: the base image's, then a `LABEL devcontainer.metadata` the user's
600-
// Dockerfile declares (#1225; the CLI's own label would otherwise clobber it),
601-
// then the config's entry as written (configLabel). With Features the Feature
602-
// build appends that entry instead.
603-
func dockerfileImageMetadata(cfg *config.DevContainer, base, stage []imagemeta.Entry, configLabel imagemeta.Entry) []imagemeta.Entry {
604-
metadata := append(append([]imagemeta.Entry{}, base...), stage...)
605-
if len(cfg.Features) == 0 {
606-
metadata = append(metadata, configLabel)
607-
}
608-
return metadata
609-
}
610-
611-
func dockerfileBaseExport(opts *buildOpts, cfg *config.DevContainer) (output string, push bool) {
612-
if len(cfg.Features) > 0 {
613-
return "", false
614-
}
615-
return opts.output, opts.push
616-
}
617-
618478
func buildxSecrets(secrets []string, useBuildx bool, logger log.Logger) []string {
619479
if useBuildx {
620480
return secrets
@@ -748,6 +608,7 @@ func (r *buildRunner) buildCompose(ctx context.Context, cfg *config.DevContainer
748608
noLockfile: opts.noLockfile,
749609
lockfileExcludeIDs: opts.lockfileExcludeIDs,
750610
caBundle: opts.caBundle,
611+
omitSyntaxDirective: opts.omitSyntaxDirective,
751612
},
752613
substitute: hostMetadataSubstitution(loadResult.HostSub, nil),
753614
configLabel: r.configLabel,
@@ -842,5 +703,6 @@ func (r *buildRunner) featureBuildOptions(cfg *config.DevContainer, hostSub *con
842703
WorkspaceFolder: opts.workspaceFolder,
843704
AdditionalMetadata: []imagemeta.Entry{configToMetadataEntry(cfg)},
844705
LabelMetadata: []imagemeta.Entry{r.configLabel},
706+
OmitSyntaxDirective: opts.omitSyntaxDirective,
845707
}
846708
}

‎internal/cli/build_held_test.go‎

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"testing"
1212

1313
"github.com/devcontainers/cli/internal/config"
14-
"github.com/devcontainers/cli/internal/imagemeta"
1514
"github.com/devcontainers/cli/internal/log"
1615
)
1716

@@ -132,40 +131,6 @@ func TestImageNamesOr(t *testing.T) {
132131
}
133132
}
134133

135-
func TestDockerfileImageMetadata(t *testing.T) {
136-
base := []imagemeta.Entry{{ID: "base"}}
137-
stage := []imagemeta.Entry{{ID: "stage"}}
138-
ids := func(entries []imagemeta.Entry) []string {
139-
var out []string
140-
for _, e := range entries {
141-
out = append(out, e.ID+"/"+e.RemoteUser)
142-
}
143-
return out
144-
}
145-
146-
cfg := &config.DevContainer{RemoteUser: "dev"}
147-
configLabel := imagemeta.Entry{RemoteUser: "${localEnv:USER}"}
148-
if got, want := ids(dockerfileImageMetadata(cfg, base, stage, configLabel)), []string{"base/", "stage/", "/${localEnv:USER}"}; !slices.Equal(got, want) {
149-
t.Errorf("without features: %v, want %v (the config's entry as written)", got, want)
150-
}
151-
152-
cfg.Features = map[string]any{"ghcr.io/devcontainers/features/go:1": true}
153-
if got, want := ids(dockerfileImageMetadata(cfg, base, stage, configLabel)), []string{"base/", "stage/"}; !slices.Equal(got, want) {
154-
t.Errorf("with features (the Feature build adds the config entry): %v, want %v", got, want)
155-
}
156-
}
157-
158-
func TestDockerfileBaseExport(t *testing.T) {
159-
opts := &buildOpts{output: "type=oci,dest=x.tar", push: true}
160-
if output, push := dockerfileBaseExport(opts, &config.DevContainer{}); output != opts.output || !push {
161-
t.Errorf("without features: (%q, %v), want the flags", output, push)
162-
}
163-
withFeature := &config.DevContainer{Features: map[string]any{"ghcr.io/devcontainers/features/go:1": true}}
164-
if output, push := dockerfileBaseExport(opts, withFeature); output != "" || push {
165-
t.Errorf("with features: (%q, %v), want them left to the Feature build", output, push)
166-
}
167-
}
168-
169134
func TestBuildxSecrets(t *testing.T) {
170135
secrets := []string{"TOKEN=x"}
171136
var logged bytes.Buffer
@@ -222,33 +187,6 @@ func TestRunBuildBuildKitNeverIgnoresBuildx(t *testing.T) {
222187
}
223188
}
224189

225-
func TestPrepareDockerfileBuildStage(t *testing.T) {
226-
ws := writeConfigFixture(t, map[string]string{
227-
".devcontainer/Dockerfile": "FROM alpine:3 AS base\nFROM base\n",
228-
".devcontainer/Empty": "RUN true\n",
229-
})
230-
cfgFile := filepath.Join(ws, ".devcontainer", "devcontainer.json")
231-
prep, err := prepareDockerfileBuild(&config.DevContainer{ConfigFilePath: cfgFile, Build: &config.Build{Dockerfile: "Dockerfile", Target: "base"}})
232-
if err != nil || prep.StageName != "base" {
233-
t.Fatalf("with a target: %+v, %v; want stage base", prep, err)
234-
}
235-
prep.Cleanup()
236-
prep, err = prepareDockerfileBuild(&config.DevContainer{ConfigFilePath: cfgFile, Build: &config.Build{Dockerfile: "Dockerfile"}})
237-
if err != nil || prep.StageName != "dev_container_auto_added_stage_label" {
238-
t.Fatalf("without a target: %+v, %v", prep, err)
239-
}
240-
if _, err := os.Stat(prep.Path); err != nil {
241-
t.Fatalf("named Dockerfile: %v", err)
242-
}
243-
prep.Cleanup()
244-
if _, err := os.Stat(prep.Path); !os.IsNotExist(err) {
245-
t.Errorf("named Dockerfile %s left after Cleanup: %v", prep.Path, err)
246-
}
247-
if _, err := prepareDockerfileBuild(&config.DevContainer{ConfigFilePath: cfgFile, Build: &config.Build{Dockerfile: "Empty"}}); err == nil || !strings.Contains(err.Error(), "no FROM instructions") {
248-
t.Errorf("no FROM: err = %v", err)
249-
}
250-
}
251-
252190
func TestBuildResultImageName(t *testing.T) {
253191
for _, tc := range []struct {
254192
name string

0 commit comments

Comments
 (0)