-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate files in dockerfiles (#219)
These changes add multistage docker files for both the operator and the operator bundle images. The builder stage uses the make targets to generate the necessary files to build the two images. This should fix the Prow CI image build issues and it should allow the copy of the bundle files in the midstream repo to be removed. Ultimately it means the same process is being use to build the images no matter what is building them.
- Loading branch information
Showing
7 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.git | ||
vendor | ||
testbin | ||
images | ||
must-gather | ||
bin | ||
api/v1/zz_generated.deepcopy.go | ||
config/crd/bases/kataconfiguration.openshift.io_kataconfigs.yaml | ||
config/rbac/role.yaml | ||
config/webhook/manifests.yaml | ||
bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Use OpenShift golang builder image | ||
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.17-openshift-4.10 AS builder | ||
|
||
WORKDIR /workspace | ||
|
||
COPY Makefile Makefile | ||
COPY PROJECT PROJECT | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY api api/ | ||
COPY config config/ | ||
COPY controllers controllers/ | ||
|
||
RUN go mod download | ||
# needed for docker build but not for local builds | ||
RUN go mod vendor | ||
|
||
# Install operator-sdk | ||
RUN export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac) \ | ||
OS=$(uname | awk '{print tolower($0)}') \ | ||
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.20.1; \ | ||
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}; \ | ||
mv operator-sdk_${OS}_${ARCH} operator-sdk; \ | ||
chmod +x operator-sdk | ||
|
||
# Set path to include local dir so standard make target can be used | ||
ENV PATH=$PATH:. | ||
|
||
# Unsetting VERSION here is workaround because the buildroot image sets VERSION to the golang version | ||
RUN unset VERSION; make bundle | ||
|
||
FROM scratch | ||
|
||
# Core bundle labels. | ||
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 | ||
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ | ||
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ | ||
LABEL operators.operatorframework.io.bundle.package.v1=sandboxed-containers-operator | ||
LABEL operators.operatorframework.io.bundle.channels.v1=stable-1.3 | ||
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable-1.3 | ||
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.19.0+git | ||
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 | ||
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 | ||
|
||
# Labels for testing. | ||
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1 | ||
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/ | ||
|
||
# Copy files to locations specified by labels. | ||
COPY --from=builder /workspace/bundle/manifests /manifests/ | ||
COPY --from=builder /workspace/bundle/metadata /metadata/ | ||
COPY --from=builder /workspace/bundle/tests/scorecard /tests/scorecard/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Use OpenShift golang builder image | ||
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.17-openshift-4.10 AS builder | ||
|
||
WORKDIR /workspace | ||
|
||
COPY Makefile Makefile | ||
COPY PROJECT PROJECT | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY api api/ | ||
COPY config config/ | ||
COPY controllers controllers/ | ||
|
||
RUN go mod download | ||
# needed for docker build but not for local builds | ||
RUN go mod vendor | ||
|
||
# Install operator-sdk | ||
RUN export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac) \ | ||
OS=$(uname | awk '{print tolower($0)}') \ | ||
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.20.1; \ | ||
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}; \ | ||
mv operator-sdk_${OS}_${ARCH} operator-sdk; \ | ||
chmod +x operator-sdk | ||
|
||
# Set path to include local dir so standard make target can be used | ||
ENV PATH=$PATH:. | ||
|
||
# Unsetting VERSION here is workaround because the buildroot image sets VERSION to the golang version | ||
RUN unset VERSION; make bundle | ||
|
||
FROM scratch | ||
|
||
# Core bundle labels. | ||
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 | ||
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ | ||
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ | ||
LABEL operators.operatorframework.io.bundle.package.v1=sandboxed-containers-operator | ||
LABEL operators.operatorframework.io.bundle.channels.v1=stable-1.3 | ||
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable-1.3 | ||
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.19.0+git | ||
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 | ||
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 | ||
|
||
# Labels for testing. | ||
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1 | ||
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/ | ||
|
||
# Copy files to locations specified by labels. | ||
COPY --from=builder /workspace/bundle/manifests /manifests/ | ||
COPY --from=builder /workspace/bundle/metadata /metadata/ | ||
COPY --from=builder /workspace/bundle/tests/scorecard /tests/scorecard/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters