Skip to content

Conversation

@ashcrow
Copy link
Member

@ashcrow ashcrow commented Aug 24, 2018

hack script to build images quickly.

$ sudo  ./hack/build-image.sh 
WHAT must be set to one of the following:
- all
- machine-config-controller
- machine-config-daemon
- machine-config-operator

Full Example

$ sudo WHAT=asd ./hack/build-image.sh 
asd is not a valid build target
$ sudo WHAT=machine-config-daemon ./hack/build-image.sh 
Using version from git...
---
Building machine-config-daemon
    Executing: podman build -t machine-config-daemon:v0.0.0-68-g57ceadb3 -f Dockerfile.machine-config-daemon
---
STEP 1: FROM golang:1.10.3
STEP 2: COPY . /go/src/github.com/openshift/machine-config-operator
STEP 3: WORKDIR /go/src/github.com/openshift/machine-config-operator
STEP 4: RUN WHAT=machine-config-daemon ./hack/build-go.sh
Using version from git...
Building github.com/openshift/machine-config-operator/cmd/machine-config-daemon (v0.0.0-68-g57ceadb3)
STEP 5: FROM scratch
STEP 6: COPY --from=build-env /go/src/github.com/openshift/machine-config-operator/_output/linux/amd64/machine-config-daemon /bin/machine-config-daemon
STEP 7: COPY templates /etc/templates
STEP 8: ENTRYPOINT ["/bin/machine-config-daemon"]
STEP 9: COMMIT containers-storage:[overlay@/var/lib/containers/storage+/var/run/containers/storage:overlay.mountopt=nodev,overlay.override_kernel_check=true]localhost/machine-config-daemon:v0.0.0-68-g57ceadb3
Getting image source signatures
Copying blob sha256:3868fd5a663c3f153c8f325bdcce83fde0bc22fd62fd299bb2ab1c0c300794d5
 8.65 MB / 8.65 MB [========================================================] 0s
Copying config sha256:f16a4582dcf7929aee5d541f3614fd6caead1369405fb70cd240c9386632b032
 399 B / 399 B [============================================================] 0s
Writing manifest to image destination
Storing signatures
--> f16a4582dcf7929aee5d541f3614fd6caead1369405fb70cd240c9386632b032

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 24, 2018
@ashcrow
Copy link
Member Author

ashcrow commented Aug 24, 2018

/cc @sdemos FYI

@openshift-ci-robot
Copy link
Contributor

@ashcrow: GitHub didn't allow me to request PR reviews from the following users: sdemos, FYI.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @sdemos FYI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

Choose a reason for hiding this comment

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

add info in README and mention the script requires podman

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

Washing through $CMD will break any quoting to protect from an invalid ${WHAT}. If we want to echo the commands being executed, we can, since we're already using Bash, use:

set -x
for IMAGE_TO_BUILD in $TOBUILD; do
  # ...test for file existence, see my earlier comment...
  podman build -t "${NAME}:${VERSION}" -f "${IMAGE_TO_BUILD}"
done

README.md Outdated
Copy link
Member

Choose a reason for hiding this comment

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

nit: We can get syntax highlighting for this with:

```console

more on using console in openshift/installer#27.

Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd rather send warnings to stderr. For example, see openshift/installer@04fa686.

I also don't see a need for the --- spacers, but if you keep them I think they should go to stderr too.

Copy link
Member

Choose a reason for hiding this comment

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

This you can replace this for loop with:

ALL_IMAGES=Dockerfile.*

Copy link
Member

Choose a reason for hiding this comment

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

No need for sed here. You can use ${parameter#word} prefix removal (defined in POSIX):

echo "- ${x#Dockerfile.}"

Copy link
Member

Choose a reason for hiding this comment

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

It's safer to quote this user-supplied information:

TOBUILD="Dockerfile.${WHAT}"

Copy link
Member

Choose a reason for hiding this comment

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

This wildcard business scares me a bit ;). Can we move the test into your for loop below?

for IMAGE_TO_BUILD in $TOBUILD; do
  if ! test -f "${IMAGE_TO_BUILD}"
  then
    echo "no build file named '${IMAGE_TO_BUILD}'" >&2
    echo "WHAT may be invalid: '${WHAT}'" >&2
    exit 1
  fi
  ...
done

Copy link
Member

Choose a reason for hiding this comment

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

NAME="${IMAGE_TO_BUILD#Dockerfile.}"

Copy link
Member

Choose a reason for hiding this comment

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

Washing through $CMD will break any quoting to protect from an invalid ${WHAT}. If we want to echo the commands being executed, we can, since we're already using Bash, use:

set -x
for IMAGE_TO_BUILD in $TOBUILD; do
  # ...test for file existence, see my earlier comment...
  podman build -t "${NAME}:${VERSION}" -f "${IMAGE_TO_BUILD}"
done

Builds one or all images. Example:

$ WHAT=machine-config-daemon ./hack/build-image.sh

WHAT targets include:

- all
- machine-config-controller
- machine-config-daemon
- machine-config-operator

Signed-off-by: Steve Milner <[email protected]>
@ashcrow
Copy link
Member Author

ashcrow commented Aug 28, 2018

Updated with review items and added two print_* functions.

@ashcrow
Copy link
Member Author

ashcrow commented Aug 29, 2018

Updated. PTAL.

Copy link
Contributor

@abhinavdahiya abhinavdahiya left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, ashcrow

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 29, 2018
@openshift-merge-robot openshift-merge-robot merged commit a61de6c into openshift:master Aug 29, 2018
osherdp pushed a commit to osherdp/machine-config-operator that referenced this pull request Apr 13, 2021
…f-reg

check for credential before process rhel install with default registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants