Skip to content
Open
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
14 changes: 13 additions & 1 deletion docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,7 @@ Valid options for `[Build]` are listed below:
| Annotation=annotation=value | --annotation=annotation=value |
| Arch=aarch64 | --arch=aarch64 |
| AuthFile=/etc/registry/auth\.json | --authfile=/etc/registry/auth\.json |
| BuildArg=foo=bar | --build-arg foo=bar |
| ContainersConfModule=/etc/nvd\.conf | --module=/etc/nvd\.conf |
| DNS=192.168.55.1 | --dns=192.168.55.1 |
| DNSOption=ndots:1 | --dns-option=ndots:1 |
Expand Down Expand Up @@ -1750,6 +1751,14 @@ Path of the authentication file.

This is equivalent to the `--authfile` option of `podman build`.

### `BuildArg=`

Specifies a build argument and its value in the same way environment variables are
(e.g., env=*value*), but it is not added to the environment variable list in the
resulting image's configuration. Can be listed multiple times.

This is equivalent to the `--build-arg` option of `podman build`.

### `ContainersConfModule=`

Load the specified containers.conf(5) module. Equivalent to the Podman `--module` option.
Expand Down Expand Up @@ -2157,7 +2166,7 @@ Yaml=/opt/k8s/deployment.yml
WantedBy=multi-user.target default.target
```

Example for locally built image to be used in a container:
Example for locally built image to be used in a container with build-specific arguments:

`test.build`
```
Expand All @@ -2169,6 +2178,9 @@ ImageTag=localhost/imagename
# expecting to find a Containerfile/Dockerfile
# + other files needed to build the image
SetWorkingDirectory=unit
# Set build arguments VERSION and DEBUG
BuildArg=VERSION=1.0 \
DEBUG=false
```

`test.container`
Expand Down
3 changes: 3 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const (
KeyArch = "Arch"
KeyAuthFile = "AuthFile"
KeyAutoUpdate = "AutoUpdate"
KeyBuildArg = "BuildArg"
KeyCertDir = "CertDir"
KeyCgroupsMode = "CgroupsMode"
KeyConfigMap = "ConfigMap"
Expand Down Expand Up @@ -433,6 +434,7 @@ var (
KeyAnnotation: true,
KeyArch: true,
KeyAuthFile: true,
KeyBuildArg: true,
KeyContainersConfModule: true,
KeyDNS: true,
KeyDNSOption: true,
Expand Down Expand Up @@ -1391,6 +1393,7 @@ func ConvertBuild(build *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU
lookupAndAddAllStrings(build, BuildGroup, allStringKeys, podman)

keyValKeys := map[string]string{
KeyBuildArg: "--build-arg",
KeyEnvironment: "--env",
KeyLabel: "--label",
KeyAnnotation: "--annotation",
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/quadlet/buildarg.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## assert-podman-args "--build-arg" "FOO=BAR"
## assert-podman-args "--build-arg" "BIZ=BAZ"
## assert-podman-args "--build-arg" "MULTIPLE=ARGUMENTS"
## assert-podman-args "--build-arg" "WORKS=FINE"


[Build]
ImageTag=image:latest
SetWorkingDirectory=unit
BuildArg=FOO=BAR
BuildArg=BIZ=BAZ
BuildArg=MULTIPLE=ARGUMENTS \
WORKS=FINE
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ BOGUS=foo
Entry("Build - Multiple Tags", "multiple-tags.build"),
Entry("Build - Network Key host", "network.build"),
Entry("Build - PodmanArgs", "podmanargs.build"),
Entry("Build - BuildArg Key", "buildarg.build"),
Entry("Build - Pull Key", "pull.build"),
Entry("Build - Secrets", "secrets.build"),
Entry("Build - SetWorkingDirectory is absolute path", "setworkingdirectory-is-abs.build"),
Expand Down