Commit Graph

77 Commits

Author SHA1 Message Date
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
Sascha Grunert 6b214d2921 Add golint linter and apply fixes
This commit enabled to golint linter in golangci-lint and applies all
necessary fixes.

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

Closes: #1740
Approved by: rhatdan
2019-07-27 09:45:49 +00:00
Valentin Rothberg f329bca692 pkg/cli: panic when flags can't be hidden
Panic when hiding the flags does not work.

Reported by golangci-lint.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1678
Approved by: rhatdan
2019-06-19 11:33:36 +00:00
Daniel J Walsh 4c6b09caf4 Default Authfile to proper path
We should show the location of the default authfile in user help

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

Closes: #1591
Approved by: TomSweeneyRedHat
2019-05-14 14:30:17 +00:00
Daniel J Walsh 0e30da6de0 Fix Transient Mounts
buildah bud is ignoring --volumes flag.

This patch parses the volumes and then passes them into the builder to be used.

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

Closes: #1559
Approved by: vrothberg
2019-04-29 12:05:39 +00:00
James Cassell cd1b62a9ad auto pass http_proxy to container
- pass all proxy env vars
- --http-proxy option for bud and from
- bash_completion and docs

Signed-off-by: James Cassell <code@james.cassell.me>

Closes: #1525
Approved by: giuseppe
2019-04-17 14:33:46 +00:00
Qi Wang d43787be28 add --dns* flags to buildah bud
use --dns* flags to change /etc/resolv.conf in the container during the build.
Signed-off-by: Qi Wang <qiwan@redhat.com>

Closes: #1491
Approved by: rhatdan
2019-04-12 21:01:30 +00:00
TomSweeneyRedHat 29f306c4b3 Fix bud-args to allow comma separation
Allow `--bud-args` to take an argument like: `PLUGINS="plugin1,plugin2,plugin3"`

Fixes #1493

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

Closes: #1495
Approved by: rhatdan
2019-04-08 13:07:07 +00:00
Daniel J Walsh 6544c55416 Fix handling of Slices versus Arrays
Cobra does not allow a "," in a StringSlice, so we should
be using StringArrays.  This fixes issues with setting
security-opts level flags.

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

Closes: #1467
Approved by: TomSweeneyRedHat
2019-04-05 01:00:20 +00:00
TomSweeneyRedHat bb764444ae Remove noop from squash help
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Removes noop note from the squash on bud --help.  This will need
to be vendored into Podman to address https://github.com/containers/libpod/issues/2568

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

Closes: #1394
Approved by: @rhatdan
2019-03-12 11:40:49 +00:00
Daniel J Walsh 8c3d8b1e45 Stop printing default twice in cli --help
Currently we are printing two defaults.  This change will
let the flags package print out the defaults.

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

Closes: #1358
Approved by: TomSweeneyRedHat
2019-02-22 21:01:13 +00:00
TomSweeneyRedHat febbaadfcc Set --disable-compression to true as documented
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

The man pages for `--disable-compression` indicates that it is
true by default.  However the code has it set to false.  This changes
that.

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

Closes: #1337
Approved by: rhatdan
2019-02-17 11:53:49 +00:00
TomSweeneyRedHat d4ddf57403 Add --target to bud command
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Add the --target option to the bud command.  This allows the
user to specify the last stage to build in a multi stage
Dockerfile.

Addresses #632

Tests:
```
cat ./bud/target/Dockerfile
FROM ubuntu:latest
RUN touch /1

FROM alpine:latest AS mytarget
RUN touch /2

FROM busybox:latest AS mytarget2
RUN touch /3

buildah bud --debug=false -t tom --target mytarget ./bud/target .
STEP 1: FROM ubuntu:latest
STEP 2: RUN touch /1
STEP 3: FROM alpine:latest AS mytarget
STEP 4: RUN touch /2
STEP 5: COMMIT containers-storage:[overlay@/var/lib/containers/storage+/var/run/containers/storage]localhost/tom:latest
Getting image source signatures
Skipping blob 503e53e365f3 (already present): 5.52 MiB / 5.52 MiB [=========] 0s
Copying blob 66e5f29a7649: 3.50 KiB / 3.50 KiB [============================] 0s
Copying config e72f1fa3d72d: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> e72f1fa3d72ddd3f23acb22a059ecce33dad571433223389e3ce92a5fd9ebae5
STEP 6: COMMIT containers-storage:[overlay@/var/lib/containers/storage+/var/run/containers/storage]localhost/tom:latest
Getting image source signatures
Skipping blob 503e53e365f3 (already present): 5.52 MiB / 5.52 MiB [=========] 0s
Skipping blob 66e5f29a7649 (already present): 3.50 KiB / 3.50 KiB [=========] 0s
Copying config e72620d8efe7: 704 B / 704 B [================================] 0s
Writing manifest to image destination
Storing signatures
--> e72620d8efe764178d1352dfb3a9a773794309ee9e879e17d3803b18553f5025

buildah images
IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/ubuntu                                 latest               20bb25d32758         Jan 22, 2019 17:41     90 MB
docker.io/library/alpine                                 latest               caf27325b298         Jan 30, 2019 17:19     5.8 MB
localhost/tom                                            latest               993ee7ded616         Feb 5, 2019 13:49      5.8 MB
```

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

Closes: #1321
Approved by: vrothberg
2019-02-13 09:09:43 +00:00
TomSweeneyRedHat ad24f284b1 Touch up cli help examples and a few nits
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Picks off a few left over nits from #1303.  Also formats the
description of each help to have a blank line then everything spaced
over by two.  Examples have been added for each too.

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

Closes: #1318
Approved by: rhatdan
2019-02-04 22:00:58 +00:00
baude 3e175b1f7a Replace urfave/cli with cobra
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1303
Approved by: rhatdan
2019-02-01 01:52:50 +00:00
Nalin Dahyabhai 23ed59594b Add options for empty-layer history entries
Add configuration methods for adding entries which will show up in a
committed image's history, both before and after the new layer that we
add while committing the image.  Expose them from the CLI in the form of
a new --add-history option for the "add", "config", "copy", and "run"
commands.

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

Closes: #1300
Approved by: rhatdan
2019-01-21 19:11:21 +00:00
Valentin Rothberg 72c1fe984a cli.BudFlags: add `--platform` nop
Add the `--platform` option for Moby/Docker CLI-compat reasons.  This
option allows to control which platform (i.e., Windows or Linux) the
image will be build on and for.  Make this a nop as Buildah supports
only Linux.

Fixes: #629
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1230
Approved by: rhatdan
2018-12-11 14:18:26 +00:00
Nalin Dahyabhai 485412ef0d Wire in a hidden --blob-cache option
Add a hidden --blob-cache option to bud, commit, from, pull, and push,
mainly so that we can exercise the APIs using integration tests.  It's
easy to accidentally get to a place where an image created while using
this option at various times won't be pushable, so for at least now, it
should stay hidden and undocumented.

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

Closes: #1149
Approved by: rhatdan
2018-12-04 18:53:15 +00:00
Nalin Dahyabhai 4243d7b8ba Add --disable-compression to 'build-using-dockerfile'
Add a --disable-compression flag to the 'build-using-dockerfile'
command, and set OCIAcceptUncompressedLayers and DirForceCompress in the
SystemContext during Commit() and Push() based on whether or not the
flag is set.

For other transports, we still end up going with the receiver's
preference, so update the man page to mention that this controls a
default.

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

Closes: #1149
Approved by: rhatdan
2018-12-04 18:53:15 +00:00
Urvashi Mohnani ed2340189d Exclude --force-rm from common bud cli flags
Need this so we can override it to true by default in podman.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>

Closes: #1163
Approved by: TomSweeneyRedHat
2018-11-08 13:57:10 +00:00
Zhou Hao b2693f6218 from: fix isolation option
Add the isolation option to the from command.

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>

Closes: #1044
Approved by: rhatdan
2018-10-02 08:09:44 +00:00