Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Parameterize builder and util images in build template #23

Merged
merged 3 commits into from
Jan 31, 2019
Merged
Changes from 2 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
84 changes: 58 additions & 26 deletions riff-cnb-clusterbuildtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,85 @@ spec:
- name: RUN_IMAGE
description: The run image buildpacks will use as the base for IMAGE.
default: packs/run:v3alpha2
- name: BUILDER_IMAGE
description: The builder image provides the buildpacks that will build the IMAGE from source.
default: projectriff/builder:latest
- name: USE_CRED_HELPERS
description: Use Docker credential helpers for Google's GCR, Amazon's ECR, or Microsoft's ACR.
default: 'true'

- name: USER_ID
description: The user ID of the builder image user
default: "1000"
- name: GROUP_ID
description: The group ID of the builder image user
default: "1000"
steps:
- name: prepare
image: packs/base
command: ["/lifecycle/knative-helper"]
image: ubuntu:18.04
command: ["/bin/sh"]
args:
- "-c"
- >
chown -R "${USER_ID}:${GROUP_ID}" "/builder/home" &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment that explains why those 2 first lines are necessary? Never got to tracking that down

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment. The packs tasks run as the pack user, and still need to be able to read these files. This behavior used to be packaged up in the /lifecycle/knative-helper which has since been removed.

chown -R "${USER_ID}:${GROUP_ID}" /layers &&
echo "artifact = '${FUNCTION_ARTIFACT}'" > /workspace/riff.toml &&
echo "handler = '${FUNCTION_HANDLER}'" >> /workspace/riff.toml &&
echo "override = '${FUNCTION_LANGUAGE}'" >> /workspace/riff.toml
volumeMounts:
- name: app-cache
mountPath: /cache
imagePullPolicy: Always
- name: write-riff-toml
image: projectriff/builder:latest
command: ["/bin/bash", "-c", "printf \"artifact = '${FUNCTION_ARTIFACT}'\\nhandler = '${FUNCTION_HANDLER}'\\noverride = '${FUNCTION_LANGUAGE}'\\n\" > app/riff.toml"]
- name: cache
mountPath: /layers
imagePullPolicy: Always
- name: detect
image: projectriff/builder:latest
image: ${BUILDER_IMAGE}
command: ["/lifecycle/detector"]
args:
- "-app=/workspace"
- "-group=/layers/group.toml"
- "-plan=/layers/plan.toml"
volumeMounts:
- name: cache
mountPath: /layers
imagePullPolicy: Always
- name: analyze
image: packs/util
image: ${BUILDER_IMAGE}
command: ["/lifecycle/analyzer"]
args: ["${IMAGE}"]
env:
- name: PACK_USE_HELPERS
value: ${USE_CRED_HELPERS}
args:
- "-layers=/layers"
- "-helpers=${USE_CRED_HELPERS}"
- "-group=/layers/group.toml"
- "${IMAGE}"
volumeMounts:
- name: cache
mountPath: /layers
imagePullPolicy: Always
- name: build
image: projectriff/builder:latest
image: ${BUILDER_IMAGE}
command: ["/lifecycle/builder"]
args:
- "-layers=/layers"
- "-app=/workspace"
- "-group=/layers/group.toml"
- "-plan=/layers/plan.toml"
volumeMounts:
- name: app-cache
mountPath: /cache
- name: cache
mountPath: /layers
imagePullPolicy: Always
- name: export
image: packs/util
image: ${BUILDER_IMAGE}
command: ["/lifecycle/exporter"]
args: ["${IMAGE}"]
env:
- name: PACK_RUN_IMAGE
value: ${RUN_IMAGE}
- name: PACK_USE_HELPERS
value: ${USE_CRED_HELPERS}
args:
- "-layers=/layers"
- "-helpers=${USE_CRED_HELPERS}"
- "-app=/workspace"
- "-image=${RUN_IMAGE}"
- "-group=/layers/group.toml"
- "${IMAGE}"
volumeMounts:
- name: cache
mountPath: /layers
imagePullPolicy: Always

volumes:
- name: app-cache
- name: cache
persistentVolumeClaim:
claimName: riff-cnb-cache