Skip to content
Merged
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
3 changes: 3 additions & 0 deletions pkg/compose/build_bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
return nil, err
}

// escape all occurrences of '$' as we interpolated everything that has to
b = bytes.ReplaceAll(b, []byte("$"), []byte("$$"))

if options.Print {
_, err = fmt.Fprintln(s.stdout(), string(b))
return nil, err
Expand Down
8 changes: 8 additions & 0 deletions pkg/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,11 @@ func TestBuildTLS(t *testing.T) {
res := icmd.RunCmd(cmd)
res.Assert(t, icmd.Expected{Err: "Built"})
}

func TestBuildEscaped(t *testing.T) {
c := NewParallelCLI(t)
// ensure local test run does not reuse previously build image
c.RunDockerOrExitError(t, "rmi", "build-test-tags")
res := c.RunDockerComposeCmd(t, "--project-directory", "./fixtures/build-test/escaped", "build", "--no-cache")
res.Assert(t, icmd.Expected{Out: "foo is ${bar}"})
}
17 changes: 17 additions & 0 deletions pkg/e2e/fixtures/build-test/escaped/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2020 Docker Compose CLI authors

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine
ARG foo
RUN echo foo is $foo
6 changes: 6 additions & 0 deletions pkg/e2e/fixtures/build-test/escaped/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
foo:
build:
context: .
args:
foo: $${bar}