Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sdk base image #3902

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,36 +159,36 @@ jobs:
name: Docker images for arm64
arch: arm64
script:
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-sdk
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk

# Build and deploy amd64 docker images
- <<: *deploy
name: Docker images for amd64
arch: amd64
script:
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-sdk
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk

# Build and deploy ppc64le docker images
- <<: *deploy
name: Docker images for ppc64le
arch: ppc64le
script:
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-sdk
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk

# Build and deploy s390x docker images
- <<: *deploy
name: Docker images for s390x
arch: s390x
script:
- make image-build-ansible image-build-helm image-build-scorecard-test
- make image-push-ansible image-push-helm image-push-scorecard-test
- make image-build-ansible image-build-helm image-build-scorecard-test image-build-sdk
- make image-push-ansible image-push-helm image-push-scorecard-test image-push-sdk

# Build and deploy ansible multi-arch manifest list
- stage: deploy-manifest-multiarch
<<: *manifest-deploy
name: Manifest lists
script:
- make image-push-ansible-multiarch image-push-helm-multiarch image-push-scorecard-test-multiarch image-push-scorecard-test-kuttl-multiarch
- make image-push-ansible-multiarch image-push-helm-multiarch image-push-scorecard-test-multiarch image-push-scorecard-test-kuttl-multiarch image-push-sdk-multiarch
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ GO_BUILD_ARGS = \

ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
OPERATOR_SDK_BASE_IMAGE = quay.io/operator-framework/operator-sdk
CUSTOM_SCORECARD_TESTS_BASE_IMAGE = quay.io/operator-framework/custom-scorecard-tests
SCORECARD_TEST_BASE_IMAGE = quay.io/operator-framework/scorecard-test
SCORECARD_TEST_KUTTL_BASE_IMAGE = quay.io/operator-framework/scorecard-test-kuttl

ANSIBLE_IMAGE ?= $(ANSIBLE_BASE_IMAGE)
HELM_IMAGE ?= $(HELM_BASE_IMAGE)
OPERATOR_SDK_IMAGE ?= $(OPERATOR_SDK_BASE_IMAGE)
CUSTOM_SCORECARD_TESTS_IMAGE ?= $(CUSTOM_SCORECARD_TESTS_BASE_IMAGE)
SCORECARD_TEST_IMAGE ?= $(SCORECARD_TEST_BASE_IMAGE)
SCORECARD_TEST_KUTTL_IMAGE ?= $(SCORECARD_TEST_KUTTL_BASE_IMAGE)

ANSIBLE_ARCHES:="amd64" "ppc64le" "arm64" "s390x"
HELM_ARCHES:="amd64" "ppc64le" "arm64" "s390x"
OPERATOR_SDK_ARCHES:="amd64" "ppc64le" "arm64" "s390x"
SCORECARD_TEST_ARCHES:="amd64" "ppc64le" "arm64" "s390x"
SCORECARD_TEST_KUTTL_ARCHES:="amd64" "ppc64le" "arm64"
# the custom scorecard test image is a scorecard example only
Expand Down Expand Up @@ -184,9 +187,9 @@ build/%.asc: ## Create release signatures for operator-sdk release binaries

image: image-build image-push ## Build and push all images

image-build: image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-custom-scorecard-tests ## Build all images
image-build: image-build-ansible image-build-helm image-build-scorecard-test image-build-scorecard-test-kuttl image-build-custom-scorecard-tests image-build-sdk ## Build all images

image-push: image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl ## Push all images
image-push: image-push-ansible image-push-helm image-push-scorecard-test image-push-scorecard-test-kuttl image-push-sdk ## Push all images

# Ansible operator image scaffold/build/push.
.PHONY: image-scaffold-ansible image-build-ansible image-push-ansible image-push-ansible-multiarch
Expand Down Expand Up @@ -218,6 +221,18 @@ image-push-helm:
image-push-helm-multiarch:
./hack/image/push-manifest-list.sh $(HELM_IMAGE) ${HELM_ARCHES}

.PHONY: image-build-sdk image-push-sdk image-push-sdk-multiarch

image-build-sdk: build/operator-sdk-dev-linux-gnu
./hack/image/build-sdk-image.sh $(OPERATOR_SDK_BASE_IMAGE):dev

image-push-sdk:
./hack/image/push-image-tags.sh $(OPERATOR_SDK_BASE_IMAGE):dev $(OPERATOR_SDK_IMAGE)-$(shell go env GOARCH)

image-push-sdk-multiarch:
./hack/image/push-manifest-list.sh $(OPERATOR_SDK_IMAGE) ${OPERATOR_SDK_ARCHES}


Copy link
Member

Choose a reason for hiding this comment

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

I think we also need an image-push-sdk-multiarch target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you elaborate on this? I figured we only needed amd64 since we are building FROM ubi-8. Do we need to support other bases as well?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think we should build it as a multi-arch image supporting all of the architectures that we produce the SDK binary for.

ubi8 is already a multiarch manifest so it should "just work" with all of the architectures we care about. I think we can just mimic what we do for the helm and ansible images.

# Scorecard test image scaffold/build/push.
.PHONY: image-build-scorecard-test image-push-scorecard-test image-push-scorecard-test-multiarch

Expand Down
18 changes: 18 additions & 0 deletions hack/image/build-sdk-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -eux

source hack/lib/test_lib.sh
source hack/lib/image_lib.sh

ROOTDIR="$(pwd)"
TMPDIR="$(mktemp -d)"
trap_add 'rm -rf $TMPDIR' EXIT

# build the base image
pushd $TMPDIR
cp $ROOTDIR/build/operator-sdk-dev-linux-gnu .
docker build -f $ROOTDIR/hack/image/sdk/Dockerfile -t $1 .

# TODO(asmacdo) any reason to load image into kind?
Copy link
Member

Choose a reason for hiding this comment

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

The caller should be doing this.

popd
5 changes: 5 additions & 0 deletions hack/image/sdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM registry.access.redhat.com/ubi8/ubi
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
FROM registry.access.redhat.com/ubi8/ubi
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest


COPY operator-sdk-dev-linux-gnu /usr/local/bin/operator-sdk
Copy link
Member

Choose a reason for hiding this comment

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

Nit, and can definitely be done later...

WDYT about making this a multi-stage dockerfile where stage 1 copies in the project and builds it, and stage 2 copies the binary from stage 1?

That would eliminate the need for the hack/image/build-sdk-image.sh script, and would be a good exemplar to convert the other image build scripts and Dockefiles over.

Copy link
Member

Choose a reason for hiding this comment

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

Actually it does look like a script may still be necessary so that we can centralize the logic around building the image and then loading it into kind. We could have a generic script (e.g. ./build-image.sh` that takes a context directory, Dockerfile, and image name) that does this work.

Given that, a follow-on probably makes more sense to do a standalone refactor of the existing Dockerfiles, build scripts, and Makefile targets.

Copy link
Member

Choose a reason for hiding this comment

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

WDYT about also setting:

ENTRYPOINT ["/usr/local/bin/operator-sdk"]

Copy link
Member Author

@asmacdo asmacdo Sep 21, 2020

Choose a reason for hiding this comment

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

@joelanford would that not print the help text exit immediately? Yeah, this simplifies the invocation.


ENTRYPOINT ["/usr/local/bin/operator-sdk"]