Commit Graph

97 Commits

Author SHA1 Message Date
Daniel J Walsh b480ce832f
Turn on rootless cgroupv2 tests
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-30 10:24:01 -05:00
Daniel J Walsh a5d9f1cb28
Add --unsetenv option to buildah commit and build
This option will allow users to remove environment variables from the
final image.

Fixes: https://github.com/containers/buildah/issues/3512

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-09 16:17:21 -05:00
Nalin Dahyabhai 100d5b12eb buildah build: add --all-platforms
Add a --all-platforms that instructs the builder to build for the
intersection of all platforms for which the build's base images are
available.  Returns an error if any of them aren't references to
manifest lists.  We've learned that we can't really trust architecture
and OS information stored in image config blobs, so we don't try to
salvage that case.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-09-29 15:43:46 -04:00
Kirill Shirinkin 2d822034f8 Rename bud to build, while keeping an alias for to bud.
Signed-off-by: Kirill Shirinkin <kirill@hey.com>
2021-08-25 17:56:58 +02:00
Nalin Dahyabhai 32c68951a4 imagebuildah: handle --manifest directly
When we're told to add built images to a manifest list, manipulate the
list ourselves, so that if we're creating a list, we won't have a
partially-populated list if some of the builds fail.

This also lets us include all of the platform information (including
variant info, which we can't sniff out after the fact) that we were
given when we started building the images.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-17 11:05:28 -04:00
openshift-ci[bot] 88f55c8f15
Merge pull request #3409 from ashley-cui/sshagent
Implement SSH RUN mount
2021-08-06 22:35:40 +00:00
Ashley Cui 3a5635f90b Implement SSH RUN mount
Allow ssh socket from host or certain ssh keys to be exposed to a
certain RUN instruction, but not any other instructions, as well as not
showing up in the final image.
This is done by spawining a new agent from buildah and mounting
the listening socket inside the run. SSH_AUTH_SOCK inside the container
will be set to the socket mountpoint. The defualt mountpoint is
/run/buildkit/ssh_agent.{i}

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-08-06 09:00:06 -04:00
Nalin Dahyabhai ae08e01e49 bud: teach --platform to take a list
Add a pkg/parse.PlatformsFromOptions() which understands a "variant"
value as an optional third value in an OS/ARCH[/VARIANT] argument value,
which accepts a comma-separated list of them, and which returns a list
of platforms.

Teach "from" and "pull" about the --platform option and add integration
tests for them, warning if --platform was given multiple values.

Add a define.BuildOptions.JobSemaphore which an imagebuildah executor
will use in preference to one that it might allocate for itself.

In main(), allocate a JobSemaphore if the number of jobs is not 0 (which
we treat as "unlimited", and continue to allow executors to do).

In addManifest(), take a lock on the manifest list's image ID so that we
don't overwrite changes that another thread might be making while we're
attempting to make changes to it.  In main(), create an empty list if
the list doesn't already exist before we start down this path, so that
we don't get two threads trying to create that manifest list at the same
time later on.  Two processes could still try to create the same list
twice, but it's an incremental improvement.

Finally, if we've been given multiple platforms to build for, run their
builds concurrently and gather up their results.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-04 15:23:10 -04:00
Dan Čermák a6b3b6f672
Add rusage-logfile flag to optionally send rusage to a file
Currently the rusage is reported to stdout and rather cumbersome to parse. The
new flag rusage-logfile can be used to specify a file to which the log will be
written instead.

Signed-off-by: Dan Čermák <dcermak@suse.com>
2021-06-02 08:07:37 +02:00
OpenShift Merge Robot 9428d03194
Merge pull request #3177 from ashley-cui/secrets
Implement RUN secrets for buildah bud
2021-04-26 08:37:00 -04:00
Ashley Cui c8002d9739 Add support for secret mounts
Add support for secrets. Secrets is a two-part flag that allows secret files to
be accessed for a certain RUN instruction, but not any other
instructions, as well as now showing up in the final image.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-04-23 09:19:43 -04:00
Daniel J Walsh bbf27625d5
Remove buildah bud --loglevel ...
This was never hooked up and just causes confusion for users.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-22 12:54:39 -04:00
Daniel J Walsh f4254eef83
Setup alias for --tty to --terminal
Need to properly handle the --tty hidden flag.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-02 08:18:14 -04:00
Daniel J Walsh 514a3f1a91
Shrink the vendoring size of pkc/cli
This PR removes the pkg/auth which brings in docker/docker
since it really is not needed, and was only there to help users
discover the settings of where the authfile was, when the environment
variables were set.  Would almost never be of any value.

Move imagebuildah.BuildOptions to define.BuildOptions

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-03 14:18:35 -05:00
Daniel J Walsh 4704e6cb3f
Eliminate the use of containers/building import in pkg subdirs
We want to shrink the size of the import when importing pkg from
buildah. This should help us shrink the size of the golang bindings
in podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-12 12:43:08 -05:00
OpenShift Merge Robot 10c10eedd2
Merge pull request #2895 from rhatdan/push
Make buildah push support pushing manifests lists and digests
2021-01-08 08:44:41 -05:00
Daniel J Walsh 57dde8e977
Make buildah push support pushing manifests lists and digests
Currently manifests just look like images in container storage.
It is surprising to the user when they go to push the images
that they end up failing, and have to use the buildah manifest push.

This patch causes buildah push to failover to buildah manifest push
if the image is a manifest.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-08 06:36:11 -05:00
Daniel J Walsh 7acdfe8e8d
Add support for --manifest flags
This patch allows users to build a multi arch image with simple commands
using emulation software.

```
buildah bud --arch arm --manifest myimage /tmp/mysrc
buildah bud --arch amd64 --manifest myimage /tmp/mysrc
buildah bud --arch s390x --manifest myimage /tmp/mysrc
```

And something like this for buildah commit
```
build() {
	ctr=$(./bin/buildah from --arch $1 ubi8)
	./bin/buildah run $ctr dnf install -y iputils
	./bin/buildah commit --manifest ubi8ping $ctr
}
build arm
build amd64
build s390x
```

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-07 14:41:02 -05:00
Daniel J Walsh 7d9b57e9e1
Use --arch and --os and --variant options to select architecture and os
Remove --override-os and --override-arch flags.

Also use --platform option if specified when generating the SystemContext.
Conflict --platform option with --os, --arch and --variant options.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-06 06:43:13 -05:00
Daniel J Walsh dc57eea023
Allow users to specify stdin into containers
Some commands within a Containerfile, might need input from users.
For example confirmation commands from Apt.

Adding a --stdin flag will allows users to interact with containers
while running inside of buildah bud.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-22 05:26:57 -05:00
TomSweeneyRedHat 7724292a4d Allow FROM to be overriden with from option
These changes will allow the "FROM" statement in a Containerfile
to be overridden with a new `--from` option.  If I have this Dockerfile.fedora

```
FROM fedora
```

This command will instead build an alpine image:

```
STEP 1: FROM alpine
Completed short name "alpine" with unqualified-search registries (origin: /etc/containers/registries.conf)
Getting image source signatures
Copying blob 188c0c94c7c5 done
Copying config d6e46aa247 done
Writing manifest to image destination
Storing signatures
STEP 2: COMMIT tom
--> d6e46aa2470
d6e46aa2470df1d32034c6707c8041158b652f38d2a9ae3d7ad7e7532d22ebe0
```

Addresses: #2404

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-12-17 19:30:53 -05:00
Giuseppe Scrivano 6eb5801723
pkg, cli: rootless uses correct isolation
when running as rootless, make sure the cli default isolation is set
to "rootless" instead of "oci".

Closes: https://github.com/containers/buildah/issues/2750

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-15 20:04:42 +01:00
Daniel J Walsh fde2597af8
Add --ignorefile flag to use alternate .dockerignore flags
Allow users to override location of the .dockerignore file.
If user specified an --ignorefile flag, buildah will read the
file and pass in the exclude lines based on the .dockerignore
contents.

Also add a --contextdir flag to buildah copy and buildah add to
specify where the context directory is located.  For these two
commands the --ignorefile flag requires the --contextdir flag.

When the --ignorefile flag is passed in, the .dockerignore files
in the context directory will be ignored.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-24 15:28:07 -05:00
OpenShift Merge Robot 3764c28b9e
Merge pull request #2749 from rhatdan/bud
Update podman bud man page
2020-11-10 08:46:34 +00:00
Daniel J Walsh fa2962a172
Move declaration of decryption-keys to common cli
We currently don't have this for Podman, so moving
it to here so it will get into podman build.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-07 06:12:10 -05:00
TomSweeneyRedHat c0d5a89a39
Verify userns-uid-map and userns-gid-map input
The format of the userns-uid-map and userns-gid-map fields must be
the form of a triple `ctrUid:hostUid:length` but we were not validating
that, doing a lot of useless processing, and then not even failing.

Addresses: #2676

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-06 14:28:47 -05:00
Paul Holzinger 67135367ff Sort build flag definitions alphabetically
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-10-02 16:11:13 +02:00
Paul Holzinger 71ba2e4ef0 Shell Completion for podman build flags
The PR containers/podman#6442 enables a new way to create
shell completions scripts. The shell completion is handled
by cobra and since the build flags are defined here
the completion functions for this should be defined here
as well. For Reference see:
https://github.com/spf13/cobra/blob/master/shell_completions.md

I added a unit test to ensure that the flags have a
completion function set.

These completions could also be used by buildah if someone
wants to implements this cobra completion logic for buildah.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-10-01 17:45:43 +02:00
Daniel J Walsh b715fb86ee
Use --timestamp rather then --omit-timestamp
We recieved feedback on the --omit-timestamp that
users would rather specify the timestamp seconds
rather then just use EPOCH.

This PR removes --omit-timestamp from buildah bud
since this has never been released.

We also hide --omit-timestamp from buildah commit
and allow users to continue to use it, but it conflicts
with --timestamp.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-28 05:23:41 -04:00
Nalin Dahyabhai b263efe70b build-using-dockerfile: add a hidden --log-rusage flag
Add a flag to imagebuildah.BuildOptions that will log timing and i/o
information at each step of the build process, and enable it if we're
given the hidden --log-rusage flag in the CLI.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-25 12:45:43 -04:00
Daniel J Walsh d05957a6f6
Change namespace handling flags to better match podman commands
Podman namespaces flags handle the options slightly differently.

Specifically namespace flag `container` is very different.
Replace the `container` option with `private` to better match podman
but continue to support `container`

Similarly Podman expects --network ns:/PATH to allow the indication of a
path to a precreated network namespace.  Buildah just supported
--network /PATH, buildah will now support both formats, but document
ns:/path.

Finally use Aliases for fix some duplicated code in buildah.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-12 16:04:57 -04:00
Daniel J Walsh 8bb100be2a
Add --omit-timestamp flag to buildah bud
Currently you can only do deterministic builds with commit command
this change will cause the metadata in the container image to be
epoch 0.

Next step is to save the data in the tar balls as 0.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-11 05:28:41 -04:00
Giuseppe Scrivano 631ecf0562
buildah, bud: support --jobs=N for parallel execution
it enables running multi stages Containerfiles in parallel.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-07-01 09:34:02 +02:00
Brandon Lum 37df2b9690 implementation of encrypt/decrypt push/pull/bud/from
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
2020-05-18 21:27:23 +00:00
Qi Wang da530c0ed5 Use c/common/pkg/auth in login/logout
use shared code for login/logout from c/common

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-04-17 16:27:03 -04:00
Daniel J Walsh bb781cf238
Update to containers/common v0.4.1
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-21 17:20:20 -05:00
Daniel J Walsh cca09881c3
Repair buildah so it can use containers.conf on the server side
In porting containers.conf to libpod, we found that buildah needed
to handle the containers.conf on the server side rather then from
the CLI.

Since the `podman-remote build` would probably not have the same content
as containers.conf on the server, the processesing of the defaults needs
to be handled in imagebuildah.  The CapAdd and CapDrop values need to be
passed in.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-10 09:41:31 -05:00
TomSweeneyRedHat 82ff48a066 Touch up os/arch doc
Touching up the OS, ARCH and PLATFORM options
doc just a bit from #2907.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2101
Approved by: rhatdan
2020-01-29 00:55:11 +00:00
Sascha Grunert 6417a9a074 Allow users to set OS and architecture on bud
When building images we now allow the architecture and operating system
to be overwritten via the new `--os` and `--arch` flags. This allows the
use case of packing pre-built or cross-compiled binaries into container
images with specifying the correct environment. The `--platform` flag
now takes the `os/arch` format into account as well.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>

Closes: #2097
Approved by: rhatdan
2020-01-21 12:25:09 +00:00
Nalin Dahyabhai a925f79cc3 add --sign-by to bud/commit/push, --remove-signatures for pull/push
Add the --sign-by option to `buildah build-using-dockerfile`,
`buildah commit`, `buildah push`, and `buildah manifest push`.  Add the
`--remove-signatures` option to `buildah pull`, `buildah push`, and
`buildah manifest push`.  We just pass them to the image library, which
does all of the heavy lifting.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #2085
Approved by: rhatdan
2020-01-17 18:22:34 +00:00
Daniel J Walsh 09d1c24e3d Add support for containers.conf
This is a rework of Qi Wang's patches.
Import package pkg/config from containers/common to read containers.conf
This patch allows users to specify default values stored in containers.conf
that will modify the behaviour of buildah tool.

Signed-off-by: Qi Wang <qiwan@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #2011
Approved by: TomSweeneyRedHat
2020-01-15 17:24:36 +00:00
TomSweeneyRedHat 6941254c29 Fix option handling for volumes in build
If the volume option was specified like: `--volume "${HOME}/.cache/zae9ujei:/myvol:rw,Z"`,
the COBRA code that processed the input from the user was considering the value to be a
SliceVar with two volumes `${HOME}/.cache/zae9ujei:/myvol:rw` and `Z` due to the comma.

Converted the COBRA code to consider the input as an ArrayVar instead and the value is
handled appropriately.  Also increased the testing to catch this going forward.

Addresses: #2000

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #2039
Approved by: rhatdan
2019-12-22 15:06:05 +00:00
Daniel J Walsh cd88667465 Ran buildah through codespell
Thanks to Dmitry Smirnov @onlyjob for suggesting this tool.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1985
Approved by: TomSweeneyRedHat
2019-11-20 17:38:41 +00:00
Qi Wang f995696f28 Check nonexsit authfile
Signed-off-by: Qi Wang <qiwan@redhat.com>

Closes: #1967
Approved by: rhatdan
2019-11-07 04:07:07 +00:00
TomSweeneyRedHat 89bc2a6a6a Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)

Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.

To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.

In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.

Changes both the from and bud commands.

Addresses: #1675

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1959
Approved by: rhatdan
2019-11-06 22:20:24 +00:00
Qi Wang 66701d43b8 remove XDG_RUNTIME_DIR from default authfile path
This patch will let authfile path default to the containers/image location for authentication file. Which for now will be xdg_runtime_dir, but eventually will switch to kernel keyring.

Signed-off-by: Qi Wang <qiwan@redhat.com>

Closes: #1947
Approved by: rhatdan
2019-10-29 03:06:55 +00:00
Nalin Dahyabhai 691c394956 buildah: add a "manifest" command
Add an initial version of a "manifest" command.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1902
Approved by: rhatdan
2019-10-28 15:15:35 +00:00
TomSweeneyRedHat d6f11ba7ad Move runtime flag to bud from common
Move the runtime Cobra flag for the build command to the
command itself and out of the common definitions.  Podman
uses the same definition and there was a collision with that
flag and the one here: https://github.com/containers/libpod/blob/master/cmd/podman/main_local.go#L69

This caused wonky results.  The podman global flag would
think it had been set, but no value was captured, or reversely,
the flag didn't think it had been set, but if you peered inside
you'd see the appropriate value from the user input.
This was all based on whether you did
`podman --runtime=/usr/bin/runc build` or
`podman build --runtime=/usr/bin/runc`

As Podman uses their runtime flag in multiple places, it's
easier to remove it from the common definition here in Buildah
and then add the flag into the bud command.

Once merged and vendored into Podman, this will fix: https://bugzilla.redhat.com/show_bug.cgi?id=1758082

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1904
Approved by: rhatdan
2019-10-11 20:55:48 +00:00
Daniel J Walsh 20a33e0791 Add --devices flag to bud and from
Some Dockerfiles (fuse-overlay) require additional devices to be in the
build environment.

This patch allows the user to specify additional devices.

Also I noticed that CapAdd and CapDrop was not working in buildah bud situations,
so this patch also fixes this.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1820
Approved by: @TomSweeneyRedHat
2019-09-07 17:32:43 +00:00
Sascha Grunert c9532167f4 Update `bud`/`from` help to contain indicator for `--dns=none`
The command line help should contain the indicator that `--dns=none` is
possble to disable the creation of the `/etc/resolv.conf` file.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>

Closes: #1774
Approved by: rhatdan
2019-08-09 13:45:53 +00:00