Skip to content

Commit 2e3b3ee

Browse files
committed
Add cosa podman-build
This is basically a thin wrapper around `podman build` to make it easier to get the arguments right. The fanciest part really is the passing of the secret repos file into the build environment. Example usage: ``` cosa podman-build node cosa podman-build extensions ``` Additional arguments are passed through to `podman build`.
1 parent 876c466 commit 2e3b3ee

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/cmd-podman-build

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
set -xeuo pipefail
3+
4+
meta=builds/latest/$(arch)/meta.json
5+
name=$(jq -r .name "${meta}")
6+
version=$(jq -r '."ostree-version"' "${meta}")
7+
8+
# can't use `rpm-ostree --print-json | jq .` here because the manifest may have
9+
# variables that need to be set
10+
ocp_version=$(python3 < src/config/packages-openshift.yaml -c '
11+
import yaml, sys
12+
y = yaml.safe_load(sys.stdin)
13+
print(y["metadata"]["ocp_version"])')
14+
15+
node_tag=localhost/${name}-${ocp_version}-${version}-node
16+
extensions_tag=localhost/${name}-${ocp_version}-${version}-extensions
17+
18+
target=${1:-}
19+
case "${target}" in
20+
node)
21+
from=oci-archive:builds/latest/$(arch)/$(jq .images.ostree.path "$meta")
22+
containerfile="src/config/Containerfile"
23+
tag=${node_tag}
24+
;;
25+
extensions)
26+
from=${node_tag}
27+
containerfile="src/config/extensions/Dockerfile"
28+
tag=${extensions_tag}
29+
;;
30+
"") echo "Usage: $0 (node|extensions) [extra podman args...]" >&2; exit 1;;
31+
esac
32+
shift
33+
34+
cat src/config/*.repo > tmp/all.repo
35+
if [ -d src/yumrepos ]; then
36+
cat src/yumrepos/*.repo >> tmp/all.repo
37+
fi
38+
repos=$(realpath tmp/all.repo)
39+
40+
set -x
41+
podman build --from "$from" \
42+
-t "${tag}" \
43+
-f "${containerfile}" \
44+
--secret id=yumrepos,src="$repos" \
45+
-v /etc/pki/ca-trust:/etc/pki/ca-trust:ro \
46+
--security-opt label=disable src/config "$@"

0 commit comments

Comments
 (0)