Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .tekton/cli-main-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
- name: path-context
value: .
- name: prefetch-input
value: '[{"type": "gomod"}, {"type": "gomod", "path": "tools/kubectl"}, {"type": "rpm"}]'
value: '[{"type": "gomod"}, {"type": "gomod", "path": "tools/kubectl"}, {"type": "gomod", "path": "tools/yq"}, {"type": "rpm"}]'
- name: build-source-image
value: "true"
- name: build-args-file
Expand Down
2 changes: 1 addition & 1 deletion .tekton/cli-main-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
- name: path-context
value: .
- name: prefetch-input
value: '[{"type": "gomod"}, {"type": "gomod", "path": "tools/kubectl"}, {"type": "rpm"}]'
value: '[{"type": "gomod"}, {"type": "gomod", "path": "tools/kubectl"}, {"type": "gomod", "path": "tools/yq"}, {"type": "rpm"}]'
- name: build-source-image
value: "true"
- name: build-args-file
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ RUN go mod download
COPY tools/kubectl/go.mod tools/kubectl/go.sum ./tools/kubectl/
RUN cd tools/kubectl && go mod download

# Cache the yq module separately from the source tree
COPY tools/yq/go.mod tools/yq/go.sum ./tools/yq/
RUN cd tools/yq && go mod download

# Now copy everything including .git
COPY . .

Expand Down Expand Up @@ -74,6 +78,9 @@ COPY --from=build "/build/dist/ec_${TARGETOS}_${TARGETARCH}" /usr/local/bin/ec
# Copy the one kubectl binary that can run in this container
COPY --from=build "/build/dist/kubectl_${TARGETOS}_${TARGETARCH}" /usr/local/bin/kubectl

# Copy the yq binary for this container's platform
COPY --from=build "/build/dist/yq_${TARGETOS}_${TARGETARCH}" /usr/local/bin/yq

# Copy reduce-snapshot script needed for single component mode
COPY hack/reduce-snapshot.sh /usr/local/bin/

Expand All @@ -94,6 +101,6 @@ RUN ln -s /usr/local/bin/ec /usr/local/bin/conforma
USER 1001

# Show some version numbers for troubleshooting purposes
RUN jq --version && ec version && ls -l /usr/local/bin
RUN jq --version && yq --version && ec version && ls -l /usr/local/bin

ENTRYPOINT ["/usr/local/bin/ec"]
9 changes: 8 additions & 1 deletion Dockerfile.dist
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ RUN go mod download
COPY tools/kubectl/go.mod tools/kubectl/go.sum ./tools/kubectl/
RUN cd tools/kubectl && go mod download

# Cache the yq module separately from the source tree
COPY tools/yq/go.mod tools/yq/go.sum ./tools/yq/
RUN cd tools/yq && go mod download

# Now copy everything including .git
COPY . .

Expand Down Expand Up @@ -75,6 +79,9 @@ COPY --from=build "/build/dist/ec_${TARGETOS}_${TARGETARCH}" /usr/local/bin/ec
# Copy the one kubectl binary that can run in this container
COPY --from=build "/build/dist/kubectl_${TARGETOS}_${TARGETARCH}" /usr/local/bin/kubectl

# Copy the yq binary for this container's platform
COPY --from=build "/build/dist/yq_${TARGETOS}_${TARGETARCH}" /usr/local/bin/yq

# Copy reduce-snapshot script needed for single component mode
COPY hack/reduce-snapshot.sh /usr/local/bin/

Expand All @@ -95,6 +102,6 @@ RUN ln -s /usr/local/bin/ec /usr/local/bin/conforma
USER 1001

# Show some version numbers for troubleshooting purposes
RUN jq --version && ec version && ls -l /usr/local/bin
RUN jq --version && yq --version && ec version && ls -l /usr/local/bin

ENTRYPOINT ["/usr/local/bin/ec"]
26 changes: 21 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ build_kubectl() {
cp "${kubectlbin}" "dist/$3_$1_$2"
}

KUBECTL_VERSION="$(go list -modfile tools/kubectl/go.mod -mod=readonly -f '{{.Version}}' -m k8s.io/kubernetes)"
build_yq() {
GOOS="$1" GOARCH="$2" CGO_ENABLED=0 GOCACHE="$GOCACHE" GOMODCACHE="$GOMODCACHE" go build \
-modfile tools/yq/go.mod \
-trimpath \
-mod=readonly \
-o "dist/yq_$1_$2" \
github.com/mikefarah/yq/v4
}

for os_arch in ${BUILDS}; do
GOOS="${os_arch%_*}"
Expand All @@ -92,8 +99,17 @@ for os_arch in ${BUILDS}; do
BINFILE="ec_${GOOS}_${GOARCH}${DOT_EXE}"
echo "Building ${BINFILE} for ${EC_FULL_VERSION}"
build_ec "${GOOS}" "${GOARCH}" "${BINFILE}" "${EC_FULL_VERSION}"

KUBECTLBIN="kubectl${DOT_EXE}"
echo "Building ${GOOS}/${GOARCH} of ${KUBECTLBIN} version ${KUBECTL_VERSION}"
build_kubectl "${GOOS}" "${GOARCH}" "${KUBECTLBIN}"
done

# yq and kubectl run inside the image; unlike ec, they are not needed for downloads.
IMAGE_OS="${TARGETOS:-$(go env GOOS)}"
IMAGE_ARCH="${TARGETARCH:-$(go env GOARCH)}"
if [[ "${IMAGE_OS}" == "linux" ]]; then
KUBECTL_VERSION="$(go list -modfile tools/kubectl/go.mod -mod=readonly -f '{{.Version}}' -m k8s.io/kubernetes)"
echo "Building ${IMAGE_OS}/${IMAGE_ARCH} of kubectl version ${KUBECTL_VERSION} for the image"
build_kubectl "${IMAGE_OS}" "${IMAGE_ARCH}" kubectl

YQ_VERSION="$(go list -modfile tools/yq/go.mod -mod=readonly -f '{{.Version}}' -m github.com/mikefarah/yq/v4)"
echo "Building ${IMAGE_OS}/${IMAGE_ARCH} of yq version ${YQ_VERSION} for the image"
build_yq "${IMAGE_OS}" "${IMAGE_ARCH}"
fi
Loading
Loading