diff --git a/.ci-operator.yaml b/.ci-operator.yaml index c3a69075b..7d8f85d88 100644 --- a/.ci-operator.yaml +++ b/.ci-operator.yaml @@ -1,4 +1,4 @@ build_root_image: name: release namespace: openshift - tag: rhel-8-release-golang-1.19-openshift-4.14 \ No newline at end of file + tag: rhel-9-release-golang-1.20-openshift-4.15 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3e6057d81..9c7cd0e4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,20 @@ -FROM openshift/origin-release:golang-1.20 AS builder +FROM registry.redhat.io/ubi9/go-toolset:1.20.12 AS builder ENV S2I_GIT_VERSION="" \ S2I_GIT_MAJOR="" \ S2I_GIT_MINOR="" - -WORKDIR /tmp/source-to-image COPY . . -USER root - -RUN make && cp _output/local/bin/linux/$(go env GOARCH)/s2i _output/local/go/bin/s2i +RUN CGO_ENABLED=0 go build -a -ldflags="-s -w" -o /tmp/s2i ./cmd/s2i # # Runner Image # -FROM registry.redhat.io/ubi8/ubi +FROM registry.redhat.io/ubi9/ubi-minimal:9.4 -COPY --from=builder /tmp/source-to-image/_output/local/go/bin/s2i /usr/local/bin/s2i +COPY --from=builder /tmp/s2i /usr/local/bin/s2i USER 1001 diff --git a/Makefile b/Makefile index 9b7601c17..4c98b13f0 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ OUT_DIR = _output export GOFLAGS +VERSION = latest +CONTAINER_ENGINE = podman + # Build code. # # Args: @@ -24,6 +27,9 @@ all build: hack/build-go.sh .PHONY: all build +build-container: + ${CONTAINER_ENGINE} build -t localhost/source-to-image/s2i:${VERSION} . + # Verify if code is properly organized. # # Example: @@ -97,6 +103,6 @@ clean: # Example: # make release release: clean - hack/build-release.sh + S2I_BUILD_CMD="${CONTAINER_ENGINE}" hack/build-release.sh hack/extract-release.sh .PHONY: release diff --git a/hack/build-release.sh b/hack/build-release.sh index 5f8cb8906..1569bf45d 100755 --- a/hack/build-release.sh +++ b/hack/build-release.sh @@ -37,11 +37,11 @@ echo "++ Building release ${S2I_GIT_VERSION}" # Perform the build and release in podman or docker. if [[ "$(go env GOHOSTOS)" == "darwin" ]]; then $buildCmd run --rm -it -e RELEASE_LDFLAGS="-w -s" \ - -v "${S2I_ROOT}":/go/src/github.com/openshift/source-to-image \ + -v "${S2I_ROOT}":/opt/app-root/src/source-to-image \ openshift/sti-release else $buildCmd run --rm -it -e RELEASE_LDFLAGS="-w -s" \ - -v "${S2I_ROOT}":/go/src/github.com/openshift/source-to-image:z \ + -v "${S2I_ROOT}":/opt/app-root/src/source-to-image:z \ openshift/sti-release fi diff --git a/images/release/Dockerfile b/images/release/Dockerfile index 1691d52b0..8fa1f07a9 100644 --- a/images/release/Dockerfile +++ b/images/release/Dockerfile @@ -3,22 +3,14 @@ # # The standard name for this image is openshift/sti-release # -FROM registry.redhat.io/ubi8/ubi +FROM registry.redhat.io/ubi9/go-toolset:1.20.12 AS builder -ENV VERSION=1.20 \ - GOARM=5 \ - GOPATH=/go \ - GOROOT=/usr/local/go \ - S2I_VERSION_FILE=/go/src/github.com/openshift/source-to-image/sti-version-defs -ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin +USER root +ENV S2I_VERSION_FILE=/opt/app-root/src/source-to-image/sti-version-defs -RUN yum install -y git gcc zip && \ - yum clean all && \ - curl https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz | tar -C /usr/local -xzf - && \ - touch /sti-build-image && \ - mkdir -p /go/src/github.com/openshift/source-to-image +RUN mkdir -p /opt/app-root/src/source-to-image -WORKDIR /go/src/github.com/openshift/source-to-image -VOLUME ["/go/src/github.com/openshift/source-to-image"] +WORKDIR /opt/app-root/src/source-to-image +VOLUME ["/opt/app-root/src/source-to-image"] # Expect source to be mounted in CMD ["./hack/build-cross.sh"]