Skip to content

Commit

Permalink
[BGD-4705] add build step for openshift image
Browse files Browse the repository at this point in the history
  • Loading branch information
ImpSy committed Mar 14, 2024
1 parent 195ccf4 commit 8e14b67
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
25 changes: 23 additions & 2 deletions .github/actions/release/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,43 @@ VERSION = $(shell git rev-parse --short=7 HEAD)
IMAGE_NAME = spark-operator
SPARK_BASE_IMAGE = gcr.io/ocean-spark/spark:platform-3.4-gen20
TAG = $(VERSION)-gen20
SPARK_BASE_IMAGE_RH = public.ecr.aws/f4k1p1n4/spark:netapp-spark-support-image-3.5.0-hadoop-3.3.4-java-11-scala-2.13-ubi-9-python-3.10-rel20240308
TAG_RH = $(VERSION)-ubi9-rel20240308

build:
build_linux:
docker buildx build --load \
-t $(REGISTRY)$(IMAGE_NAME):$(TAG) \
--build-arg SPARK_IMAGE=$(SPARK_BASE_IMAGE) .

push:
build_rh:
docker buildx build --load \
-t $(REGISTRY)$(IMAGE_NAME):$(TAG_RH) \
-f Dockerfile.rh \
--build-arg SPARK_IMAGE=$(SPARK_BASE_IMAGE_RH) .

build: build_linux build_rh

push_linux:
docker tag $(REGISTRY)$(IMAGE_NAME):$(TAG) $(REGISTRY)$(IMAGE_NAME):${BRANCH}
docker push $(REGISTRY)$(IMAGE_NAME):${BRANCH}
@if [ "$(BRANCH)" = "ocean-spark" ]; then \
docker push $(REGISTRY)$(IMAGE_NAME):$(TAG); \
fi

push_rh:
docker tag $(REGISTRY)$(IMAGE_NAME):$(TAG_RH) $(REGISTRY)$(IMAGE_NAME):${BRANCH}-rh
docker push $(REGISTRY)$(IMAGE_NAME):${BRANCH}-rh
@if [ "$(BRANCH)" = "ocean-spark" ]; then \
docker push $(REGISTRY)$(IMAGE_NAME):$(TAG_RH); \
fi

push: push_linux push_rh

show:
@echo "Images available:"
@if [ "$(BRANCH)" = "ocean-spark" ]; then \
echo "-> $(REGISTRY)$(IMAGE_NAME):$(TAG)"; \
echo "-> $(REGISTRY)$(IMAGE_NAME):$(TAG_RH)"; \
fi
@echo "-> $(REGISTRY)$(IMAGE_NAME):${BRANCH}"
@echo "-> $(REGISTRY)$(IMAGE_NAME):${BRANCH}-rh"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ sparkctl/sparkctl
spark-on-k8s-operator
sparkctl/sparkctl-linux-amd64
sparkctl/sparkctl-darwin-amd64

.DS_Store
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

ARG SPARK_IMAGE=gcr.io/spark-operator/spark:v3.1.1

FROM golang:1.19.2-alpine as builder
FROM golang:1.20-alpine as builder

RUN apk update && apk add --no-cache libcap

Expand Down
24 changes: 17 additions & 7 deletions Dockerfile.rh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

ARG SPARK_IMAGE=gcr.io/spark-operator/spark:v3.1.1

FROM golang:1.14.0-alpine as builder
FROM golang:1.20-alpine as builder

RUN apk update && apk add --no-cache libcap

WORKDIR /workspace

Expand All @@ -39,19 +41,27 @@ COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o /usr/bin/spark-operator main.go
RUN setcap cap_net_bind_service=+ep /usr/bin/spark-operator

FROM ${SPARK_IMAGE}
COPY --from=builder /usr/bin/spark-operator /usr/bin/
USER root
RUN yum install -y openssl \
&& yum clean all \
&& curl -fsSL "https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-amd64" -o /sbin/tini \
&& chmod +x /sbin/tini

# Comment out the following three lines if you do not have a RedHat subscription.
COPY hack/install_packages.sh /
RUN --mount=target=/opt/spark/credentials,type=secret,id=credentials,required /install_packages.sh
RUN rm /install_packages.sh
# COPY hack/install_packages.sh /
# RUN --mount=target=/opt/spark/credentials,type=secret,id=credentials,required /install_packages.sh
# RUN rm /install_packages.sh

RUN chmod -R u+x /tmp
# RUN chmod -R u+x /tmp

USER 185

COPY --from=builder /usr/bin/spark-operator /usr/bin/
COPY hack/gencerts.sh /usr/bin/

COPY entrypoint.sh /usr/bin/
USER 185
ENTRYPOINT ["/usr/bin/entrypoint.sh"]

0 comments on commit 8e14b67

Please sign in to comment.