Skip to content

Commit

Permalink
Merge pull request #4555 from werf/feat-container-runtime-autodetection
Browse files Browse the repository at this point in the history
feat(buildah): container runtime autodetection
  • Loading branch information
ilya-lesikov committed Jun 17, 2022
2 parents 9082632 + 041d962 commit 71b152e
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/pages_en/advanced/buildah_mode.md
Expand Up @@ -28,7 +28,7 @@ Buildah is enabled by setting the `WERF_BUILDAH_MODE` environment variable to on

* `auto` — select the mode automatically based on your platform and environment.
* `native-chroot` works only on Linux and uses the `chroot` isolation level when running build containers.
* `native-rootless` works only on Linux and uses the `rootless` isolation level when running build containers. At this isolation level werf will use container runtime (runc or crun).
* `native-rootless` works only on Linux and uses the `rootless` isolation level when running build containers. At this isolation level werf will use container runtime (runc, crun, kata or runsc).
* `docker-with-fuse` is a cross-platform mode and is the only choice available on MacOS or Windows.

Most users only need to set `WERF_BUILDAH_MODE=auto` to enable the experimental Buildah-based mode.
Expand Down
2 changes: 1 addition & 1 deletion docs/pages_ru/advanced/buildah_mode.md
Expand Up @@ -28,7 +28,7 @@ Buildah включается установкой переменной окру

* `auto` — автоматический выбор режима в зависимости от платформы и окружения;
* `native-chroot` работает только в Linux и использует `chroot`-изоляцию для сборочных контейнеров;
* `native-rootless` работает только в Linux и использует `rootless`-изоляцию для сборочных контейнеров. На этом уровне изоляции werf использует среду выполнения сборочных операций в контейнерах (runc или crun).
* `native-rootless` работает только в Linux и использует `rootless`-изоляцию для сборочных контейнеров. На этом уровне изоляции werf использует среду выполнения сборочных операций в контейнерах (runc, crun, kata или runsc).
* `docker-with-fuse` — только этот кроссплатформенный режим доступен для MacOS или Windows.

Большинству пользователей для включения экспериментального режима Buildah достаточно установить `WERF_BUILDAH_MODE=auto`.
Expand Down
1 change: 0 additions & 1 deletion pkg/buildah/common.go
Expand Up @@ -20,7 +20,6 @@ const (
DefaultShmSize = "65536k"
DefaultSignaturePolicy = `{"default": [{"type": "insecureAcceptAnything"}], "transports": {"docker-daemon": {"": [{"type": "insecureAcceptAnything"}]}}}`
DefaultRegistriesConfig = `unqualified-search-registries = ["docker.io"]`
DefaultRuntime = "crun"
BuildahImage = "registry.werf.io/werf/buildah:v1.22.3-1"
BuildahStorageContainerName = "werf-buildah-storage"

Expand Down
2 changes: 1 addition & 1 deletion pkg/buildah/docker_with_fuse.go
Expand Up @@ -124,7 +124,7 @@ func (b *DockerWithFuseBuildah) BuildFromDockerfile(ctx context.Context, dockerf
}

func (b *DockerWithFuseBuildah) RunCommand(ctx context.Context, container string, command []string, opts RunCommandOpts) error {
_, _, err := b.runBuildah(ctx, []string{}, append([]string{"run", "--isolation", b.Isolation.String(), "--runtime", DefaultRuntime, container}, command...), opts.LogWriter)
_, _, err := b.runBuildah(ctx, []string{}, append([]string{"run", "--isolation", b.Isolation.String(), container}, command...), opts.LogWriter)
return err
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/buildah/native_linux.go
Expand Up @@ -184,7 +184,6 @@ func (b *NativeBuildah) Push(ctx context.Context, ref string, opts PushOpts) err
func (b *NativeBuildah) BuildFromDockerfile(ctx context.Context, dockerfile []byte, opts BuildFromDockerfileOpts) (string, error) {
buildOpts := define.BuildOptions{
Isolation: define.Isolation(b.Isolation),
Runtime: DefaultRuntime,
Args: opts.BuildArgs,
SignaturePolicyPath: b.SignaturePolicyPath,
ReportWriter: opts.LogWriter,
Expand Down Expand Up @@ -250,7 +249,6 @@ func (b *NativeBuildah) Umount(ctx context.Context, container string, opts Umoun
func (b *NativeBuildah) RunCommand(ctx context.Context, container string, command []string, opts RunCommandOpts) error {
runOpts := buildah.RunOptions{
Isolation: define.Isolation(b.Isolation),
Runtime: DefaultRuntime,
Args: opts.Args,
Mounts: opts.Mounts,
ConfigureNetwork: define.NetworkEnabled,
Expand Down

0 comments on commit 71b152e

Please sign in to comment.