Skip to content

Commit 1602b49

Browse files
authored
Merge pull request #1926 from jedevc/v0.11-cherry-picks
2 parents ff87dd1 + 94baaf3 commit 1602b49

21 files changed

Lines changed: 194 additions & 75 deletions

File tree

Dockerfile

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
ARG GO_VERSION=1.20
44
ARG XX_VERSION=1.2.1
5-
ARG DOCKERD_VERSION=20.10.14
5+
6+
ARG DOCKER_VERSION=24.0.2
67
ARG GOTESTSUM_VERSION=v1.9.0
78
ARG REGISTRY_VERSION=2.8.0
89
ARG BUILDKIT_VERSION=v0.11.6
910

10-
FROM docker:$DOCKERD_VERSION AS dockerd-release
11-
1211
# xx is a helper for cross-compilation
1312
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
1413

@@ -25,6 +24,22 @@ FROM registry:$REGISTRY_VERSION AS registry
2524

2625
FROM moby/buildkit:$BUILDKIT_VERSION AS buildkit
2726

27+
FROM gobase AS docker
28+
ARG TARGETPLATFORM
29+
ARG DOCKER_VERSION
30+
WORKDIR /opt/docker
31+
RUN DOCKER_ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
32+
"linux/amd64") echo "x86_64" ;; \
33+
"linux/arm/v6") echo "armel" ;; \
34+
"linux/arm/v7") echo "armhf" ;; \
35+
"linux/arm64") echo "aarch64" ;; \
36+
"linux/ppc64le") echo "ppc64le" ;; \
37+
"linux/s390x") echo "s390x" ;; \
38+
*) echo "" ;; esac) \
39+
&& echo "DOCKER_ARCH=$DOCKER_ARCH" \
40+
&& wget -qO- "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz" | tar xvz --strip 1
41+
RUN ./dockerd --version && ./containerd --version && ./ctr --version && ./runc --version
42+
2843
FROM gobase AS gotestsum
2944
ARG GOTESTSUM_VERSION
3045
ENV GOFLAGS=
@@ -77,9 +92,20 @@ FROM binaries-$TARGETOS AS binaries
7792
ARG BUILDKIT_SBOM_SCAN_STAGE=true
7893

7994
FROM gobase AS integration-test-base
80-
RUN apk add --no-cache docker runc containerd
95+
# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
96+
RUN apk add --no-cache \
97+
btrfs-progs \
98+
e2fsprogs \
99+
e2fsprogs-extra \
100+
ip6tables \
101+
iptables \
102+
openssl \
103+
shadow-uidmap \
104+
xfsprogs \
105+
xz
81106
COPY --link --from=gotestsum /out/gotestsum /usr/bin/
82107
COPY --link --from=registry /bin/registry /usr/bin/
108+
COPY --link --from=docker /opt/docker/* /usr/bin/
83109
COPY --link --from=buildkit /usr/bin/buildkitd /usr/bin/
84110
COPY --link --from=buildkit /usr/bin/buildctl /usr/bin/
85111
COPY --link --from=binaries /buildx /usr/bin/
@@ -102,7 +128,7 @@ FROM scratch AS release
102128
COPY --from=releaser /out/ /
103129

104130
# Shell
105-
FROM docker:$DOCKERD_VERSION AS dockerd-release
131+
FROM docker:$DOCKER_VERSION AS dockerd-release
106132
FROM alpine AS shell
107133
RUN apk add --no-cache iptables tmux git vim less openssh
108134
RUN mkdir -p /usr/local/lib/docker/cli-plugins && ln -s /usr/local/bin/buildx /usr/local/lib/docker/cli-plugins/docker-buildx

bake/compose.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func ParseCompose(cfgs []compose.ConfigFile, envs map[string]string) (*Config, e
3737
}, func(options *loader.Options) {
3838
options.SetProjectName("bake", false)
3939
options.SkipNormalization = true
40+
options.Profiles = []string{"*"}
4041
})
4142
if err != nil {
4243
return nil, err

bake/compose_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ services:
3636
- token
3737
- aws
3838
webapp2:
39+
profiles:
40+
- test
3941
build:
4042
context: ./dir
4143
dockerfile_inline: |

build/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
642642
}
643643

644644
// setup extrahosts
645-
extraHosts, err := toBuildkitExtraHosts(opt.ExtraHosts, nodeDriver.IsMobyDriver())
645+
extraHosts, err := toBuildkitExtraHosts(ctx, opt.ExtraHosts, nodeDriver)
646646
if err != nil {
647647
return nil, nil, err
648648
}

build/utils.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package build
33
import (
44
"archive/tar"
55
"bytes"
6+
"context"
67
"net"
78
"os"
89
"strings"
910

11+
"github.com/docker/buildx/driver"
1012
"github.com/docker/cli/opts"
1113
"github.com/docker/docker/builder/remotecontext/urlutil"
1214
"github.com/moby/buildkit/util/gitutil"
@@ -57,7 +59,7 @@ func isArchive(header []byte) bool {
5759
}
5860

5961
// toBuildkitExtraHosts converts hosts from docker key:value format to buildkit's csv format
60-
func toBuildkitExtraHosts(inp []string, mobyDriver bool) (string, error) {
62+
func toBuildkitExtraHosts(ctx context.Context, inp []string, nodeDriver *driver.DriverHandle) (string, error) {
6163
if len(inp) == 0 {
6264
return "", nil
6365
}
@@ -67,11 +69,16 @@ func toBuildkitExtraHosts(inp []string, mobyDriver bool) (string, error) {
6769
if !ok || host == "" || ip == "" {
6870
return "", errors.Errorf("invalid host %s", h)
6971
}
70-
// Skip IP address validation for "host-gateway" string with moby driver
71-
if !mobyDriver || ip != mobyHostGatewayName {
72-
if net.ParseIP(ip) == nil {
73-
return "", errors.Errorf("invalid host %s", h)
72+
// If the IP Address is a "host-gateway", replace this value with the
73+
// IP address provided by the worker's label.
74+
if ip == mobyHostGatewayName {
75+
hgip, err := nodeDriver.HostGatewayIP(ctx)
76+
if err != nil {
77+
return "", errors.Wrap(err, "unable to derive the IP value for host-gateway")
7478
}
79+
ip = hgip.String()
80+
} else if net.ParseIP(ip) == nil {
81+
return "", errors.Errorf("invalid host %s", h)
7582
}
7683
hosts = append(hosts, host+"="+ip)
7784
}

commands/build.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
487487
flags.StringArrayVar(&options.platforms, "platform", platformsDefault, "Set target platform for build")
488488

489489
if isExperimental() {
490-
flags.StringVar(&options.printFunc, "print", "", "Print result of information request (e.g., outline, targets) [experimental]")
490+
flags.StringVar(&options.printFunc, "print", "", "Print result of information request (e.g., outline, targets)")
491+
flags.SetAnnotation("print", "experimentalCLI", nil)
491492
}
492493

493494
flags.BoolVar(&options.exportPush, "push", false, `Shorthand for "--output=type=registry"`)
@@ -514,10 +515,14 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
514515
flags.StringVar(&options.provenance, "provenance", "", `Shorthand for "--attest=type=provenance"`)
515516

516517
if isExperimental() {
517-
flags.StringVar(&invokeFlag, "invoke", "", "Invoke a command after the build [experimental]")
518-
flags.StringVar(&options.Root, "root", "", "Specify root directory of server to connect [experimental]")
519-
flags.BoolVar(&options.Detach, "detach", false, "Detach buildx server (supported only on linux) [experimental]")
520-
flags.StringVar(&options.ServerConfig, "server-config", "", "Specify buildx server config file (used only when launching new server) [experimental]")
518+
flags.StringVar(&invokeFlag, "invoke", "", "Invoke a command after the build")
519+
flags.SetAnnotation("invoke", "experimentalCLI", nil)
520+
flags.StringVar(&options.Root, "root", "", "Specify root directory of server to connect")
521+
flags.SetAnnotation("root", "experimentalCLI", nil)
522+
flags.BoolVar(&options.Detach, "detach", false, "Detach buildx server (supported only on linux)")
523+
flags.SetAnnotation("detach", "experimentalCLI", nil)
524+
flags.StringVar(&options.ServerConfig, "server-config", "", "Specify buildx server config file (used only when launching new server)")
525+
flags.SetAnnotation("server-config", "experimentalCLI", nil)
521526
}
522527

523528
// hidden flags
@@ -540,6 +545,7 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
540545
flags.BoolVar(&ignoreBool, "squash", false, "Squash newly built layers into a single new layer")
541546
flags.MarkHidden("squash")
542547
flags.SetAnnotation("squash", "flag-warn", []string{"experimental flag squash is removed with BuildKit. You should squash inside build using a multi-stage Dockerfile for efficiency."})
548+
flags.SetAnnotation("squash", "experimentalCLI", nil)
543549

544550
flags.StringVarP(&ignore, "memory", "m", "", "Memory limit")
545551
flags.MarkHidden("memory")

commands/debug-shell.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ func debugShellCmd(dockerCli command.Cli) *cobra.Command {
2424
cmd := &cobra.Command{
2525
Use: "debug-shell",
2626
Short: "Start a monitor",
27+
Annotations: map[string]string{
28+
"experimentalCLI": "",
29+
},
2730
RunE: func(cmd *cobra.Command, args []string) error {
2831
printer, err := progress.NewPrinter(context.TODO(), os.Stderr, os.Stderr, progressMode)
2932
if err != nil {
@@ -55,9 +58,15 @@ func debugShellCmd(dockerCli command.Cli) *cobra.Command {
5558

5659
flags := cmd.Flags()
5760

58-
flags.StringVar(&options.Root, "root", "", "Specify root directory of server to connect [experimental]")
59-
flags.BoolVar(&options.Detach, "detach", runtime.GOOS == "linux", "Detach buildx server (supported only on linux) [experimental]")
60-
flags.StringVar(&options.ServerConfig, "server-config", "", "Specify buildx server config file (used only when launching new server) [experimental]")
61+
flags.StringVar(&options.Root, "root", "", "Specify root directory of server to connect")
62+
flags.SetAnnotation("root", "experimentalCLI", nil)
63+
64+
flags.BoolVar(&options.Detach, "detach", runtime.GOOS == "linux", "Detach buildx server (supported only on linux)")
65+
flags.SetAnnotation("detach", "experimentalCLI", nil)
66+
67+
flags.StringVar(&options.ServerConfig, "server-config", "", "Specify buildx server config file (used only when launching new server)")
68+
flags.SetAnnotation("server-config", "experimentalCLI", nil)
69+
6170
flags.StringVar(&progressMode, "progress", "auto", `Set type of progress output ("auto", "plain", "tty"). Use plain to show container output`)
6271

6372
return cmd

controller/build/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
5454
NamedContexts: contexts,
5555
},
5656
BuildArgs: in.BuildArgs,
57+
CgroupParent: in.CgroupParent,
5758
ExtraHosts: in.ExtraHosts,
5859
Labels: in.Labels,
5960
NetworkMode: in.NetworkMode,

docs/reference/buildx.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,21 @@ Extended build capabilities with BuildKit
99

1010
### Subcommands
1111

12-
| Name | Description |
13-
|:-----------------------------------------------|:-------------------------------------------|
14-
| [`_INTERNAL_SERVE`](buildx__INTERNAL_SERVE.md) | |
15-
| [`bake`](buildx_bake.md) | Build from a file |
16-
| [`build`](buildx_build.md) | Start a build |
17-
| [`create`](buildx_create.md) | Create a new builder instance |
18-
| [`debug-shell`](buildx_debug-shell.md) | Start a monitor |
19-
| [`du`](buildx_du.md) | Disk usage |
20-
| [`imagetools`](buildx_imagetools.md) | Commands to work on images in registry |
21-
| [`inspect`](buildx_inspect.md) | Inspect current builder instance |
22-
| [`install`](buildx_install.md) | Install buildx as a 'docker builder' alias |
23-
| [`ls`](buildx_ls.md) | List builder instances |
24-
| [`prune`](buildx_prune.md) | Remove build cache |
25-
| [`rm`](buildx_rm.md) | Remove a builder instance |
26-
| [`stop`](buildx_stop.md) | Stop builder instance |
27-
| [`uninstall`](buildx_uninstall.md) | Uninstall the 'docker builder' alias |
28-
| [`use`](buildx_use.md) | Set the current builder instance |
29-
| [`version`](buildx_version.md) | Show buildx version information |
12+
| Name | Description |
13+
|:---------------------------------------|:---------------------------------------|
14+
| [`bake`](buildx_bake.md) | Build from a file |
15+
| [`build`](buildx_build.md) | Start a build |
16+
| [`create`](buildx_create.md) | Create a new builder instance |
17+
| [`debug-shell`](buildx_debug-shell.md) | Start a monitor |
18+
| [`du`](buildx_du.md) | Disk usage |
19+
| [`imagetools`](buildx_imagetools.md) | Commands to work on images in registry |
20+
| [`inspect`](buildx_inspect.md) | Inspect current builder instance |
21+
| [`ls`](buildx_ls.md) | List builder instances |
22+
| [`prune`](buildx_prune.md) | Remove build cache |
23+
| [`rm`](buildx_rm.md) | Remove a builder instance |
24+
| [`stop`](buildx_stop.md) | Stop builder instance |
25+
| [`use`](buildx_use.md) | Set the current builder instance |
26+
| [`version`](buildx_version.md) | Show buildx version information |
3027

3128

3229
### Options

0 commit comments

Comments
 (0)