The apb tooling adds very little value outside of apb prepare
, which simply base64 encodes apb.yml, specifically base64 --wrap=0 apb.yml
as an image label, a.k.a. "Dockerfile label". This value may be passed into an OpenShift buildconfig object.
apiVersion: v1
kind: BuildConfig
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewBuild
creationTimestamp: 2017-08-01T17:57:08Z
labels:
build: hello-world-apb
name: hello-world-apb
namespace: myproject
resourceVersion: "77735"
selfLink: /oapi/v1/namespaces/myproject/buildconfigs/hello-world-apb
uid: d619c306-76e2-11e7-9c8b-54ee75102ab0
spec:
nodeSelector: null
output:
imageLabels:
- name: com.redhat.apb.spec-test
value: aWQ6IDU1YzUzYTVkLTY1YTYtNGMyNy04OGZjLWUwMjc0MTBiMTg4MgpuYW1lOiBoZWxsby13b3JsZC1hcGIKaW1hZ2U6IGFuc2libGVwbGF5Ym9va2J1bmRsZS9oZWxsby13b3JsZC1hcGIKZGVzY3JpcHRpb246IGhlbGxvLXdvcmxkLWFwYiBkZXNjcmlwdGlvbgpiaW5kYWJsZTogRmFsc2UKYXN5bmM6IG9wdGlvbmFsCm1ldGFkYXRhOgogIGRpc3BsYXlOYW1lOiBIZWxsbyBXb3JsZAogIGRlcGVuZGVuY2llczogWydkb2NrZXIuaW8vYW5zaWJsZXBsYXlib29rYnVuZGxlL2hlbGxvLXdvcmxkOmxhdGVzdCddCgpwYXJhbWV0ZXJzOiBbXQoKcmVxdWlyZWQ6IFtdCg==
to:
kind: ImageStreamTag
name: hello-world-apb:latest
...
Neither oc new-build ...
nor oc start-build ...
accept overriding imageLables. In this workflow we assume the initial buildconfig object has been created. The APB source has been updated.
-
Patch the buildconfig object. Note: the apb.yml is checked into source. This may be best handled by a Jenkins job. Example patch command:
oc patch bc/hello-world-apb --patch="{\"spec\": {\"output\": {\"imageLabels\":[{\"name\":\"com.redhat.apb.spec\", \"value\": \"$(base64 --wrap=0 apb.yml)\"}]}}}"
-
Start new build
oc start-build hello-world-apb
Alternatively, building an image using docker CLI allows adding arbitrary labels during build.
-
Remove the
com.redhat.apb.spec
label from the Dockerfile (the default trailing slash causes a syntax error). -
Build using this command, base64 encoding the apb.yaml file as a label:
$ sudo docker build --label "com.redhat.apb.spec=$(base64 --wrap=0 apb.yml)" -t apb-test .