diff --git a/.github/workflows/platsec.yml b/.github/workflows/platsec.yml index 1e918723..2a119e1c 100644 --- a/.github/workflows/platsec.yml +++ b/.github/workflows/platsec.yml @@ -40,5 +40,4 @@ jobs: # dockerfile_name: 'Dockerfile.main' base_image_build: true # base_dockerfile_path: './test' - base_dockerfile_name: 'Dockerfile.base' - build_arg: '--build-arg BASE_IMAGE="localbuild/baseimage:latest"' + base_dockerfile_name: 'Dockerfile' diff --git a/Dockerfile b/Dockerfile index 828dffc1..324c9bf0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,27 @@ # Build the manager binary -ARG BASE_IMAGE= -FROM $BASE_IMAGE as builder +FROM registry.access.redhat.com/ubi8/go-toolset:1.19.13-2.1698062273 as base + +WORKDIR /workspace + +COPY go.mod go.mod +COPY go.sum go.sum + +RUN go mod download + +COPY main.go main.go +COPY api/ api/ +COPY controllers/ controllers/ + +USER 0 + +RUN CGO_ENABLED=0 GOOS=linux go build -o manager main.go + +RUN rm main.go +RUN rm -rf api +RUN rm -rf controllers + +# Build the manager binary +FROM base as builder WORKDIR /workspace diff --git a/Dockerfile.base b/Dockerfile.base deleted file mode 100644 index 0ded5606..00000000 --- a/Dockerfile.base +++ /dev/null @@ -1,23 +0,0 @@ -# Build the manager binary -FROM registry.access.redhat.com/ubi8/go-toolset:1.19.13-2.1698062273 as builder - -WORKDIR /workspace - -COPY go.mod go.mod -COPY go.sum go.sum - - -RUN go mod download - -COPY main.go main.go -COPY api/ api/ -COPY controllers/ controllers/ - -USER 0 - -RUN CGO_ENABLED=0 GOOS=linux go build -o manager main.go - -RUN rm main.go -RUN rm -rf api -RUN rm -rf controllers - diff --git a/build_deploy.sh b/build_deploy.sh index de0d1bf7..6cc99ab2 100755 --- a/build_deploy.sh +++ b/build_deploy.sh @@ -19,49 +19,18 @@ fi DOCKER_CONF="$PWD/.docker" mkdir -p "$DOCKER_CONF" - - - docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io docker login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io -### Start base image build and push -BASE_TAG=`cat go.mod go.sum Dockerfile.base | sha256sum | head -c 8` -BASE_IMG=quay.io/cloudservices/frontend-operator-build-base:$BASE_TAG -RESPONSE=$( \ - curl -Ls -H "Authorization: Bearer $QUAY_TOKEN" \ - "https://quay.io/api/v1/repository/cloudservices/frontend-operator-build-base/tag/?specificTag=$BASE_TAG" \ - ) -echo "received HTTP response: $RESPONSE" -# find all non-expired tags -VALID_TAGS_LENGTH=$(echo $RESPONSE | jq '[ .tags[] | select(.end_ts == null) ] | length') - -if [[ "$VALID_TAGS_LENGTH" -eq 0 ]]; then - # Check if the multiarchbuilder exists - if docker buildx ls | grep -q "multiarchbuilder"; then - docker buildx use multiarchbuilder - echo "Using multiarchbuilder for buildx" - # Multi-architecture build - docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile.base -t "${BASE_IMG}" --push . - else - echo "Falling back to standard build and push" - # Standard build and push - docker build -t "${BASE_IMG}" -f Dockerfile.base - docker push "${BASE_IMG}" - fi -fi -#### End - - # Check if the multiarchbuilder exists if docker buildx ls | grep -q "multiarchbuilder"; then docker buildx use multiarchbuilder echo "Using multiarchbuilder for buildx" # Multi-architecture build - docker buildx build --platform linux/amd64,linux/arm64 --build-arg BASE_IMAGE="${BASE_IMG}" -t "${IMAGE}:${IMAGE_TAG}" --push . + docker buildx build --platform linux/amd64,linux/arm64 -t "${IMAGE}:${IMAGE_TAG}" --push . else echo "Falling back to standard build and push" # Standard build and push - docker build -t "${IMAGE}:${IMAGE_TAG}" --build-arg BASE_IMAGE="${BASE_IMG}" . + docker build -t "${IMAGE}:${IMAGE_TAG}" . docker push "${IMAGE}:${IMAGE_TAG}" fi