Skip to content

Commit 874fac2

Browse files
author
Ish Shah
authored
Implement Scorecard 2 Base Image (#2837)
* scorecard 2 base image * remove extra chmod * fix test user entrypoint * update according to 2469
1 parent cf78347 commit 874fac2

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ SOURCES = $(shell find . -name '*.go' -not -path "*/vendor/*")
2121
ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
2222
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
2323
SCORECARD_PROXY_BASE_IMAGE = quay.io/operator-framework/scorecard-proxy
24+
SCORECARD_TEST_BASE_IMAGE = quay.io/operator-framework/scorecard-test
2425

2526
ANSIBLE_IMAGE ?= $(ANSIBLE_BASE_IMAGE)
2627
HELM_IMAGE ?= $(HELM_BASE_IMAGE)
2728
SCORECARD_PROXY_IMAGE ?= $(SCORECARD_PROXY_BASE_IMAGE)
29+
SCORECARD_TEST_IMAGE ?= $(SCORECARD_TEST_BASE_IMAGE)
2830

2931
ANSIBLE_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
3032
HELM_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
@@ -171,6 +173,9 @@ image-build-helm: build/operator-sdk-dev-linux-gnu
171173
image-build-scorecard-proxy:
172174
./hack/image/build-scorecard-proxy-image.sh $(SCORECARD_PROXY_BASE_IMAGE):dev
173175

176+
image-build-scorecard-test:
177+
./hack/image/build-scorecard-test-image.sh $(SCORECARD_TEST_BASE_IMAGE):dev
178+
174179
image-push: image-push-ansible image-push-helm image-push-scorecard-proxy ## Push all images
175180

176181
image-push-ansible:
@@ -191,6 +196,9 @@ image-push-scorecard-proxy:
191196
image-push-scorecard-proxy-multiarch:
192197
./hack/image/push-manifest-list.sh $(SCORECARD_PROXY_IMAGE) ${SCORECARD_PROXY_ARCHES}
193198

199+
image-push-scorecard-test:
200+
./hack/image/push-image-tags.sh $(SCORECARD_TEST_BASE_IMAGE):dev $(SCORECARD_TEST_IMAGE)-$(shell go env GOARCH)
201+
194202
##############################
195203
# Tests #
196204
##############################
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
source hack/lib/image_lib.sh
6+
7+
# TODO build test image
8+
#WD="$(dirname "$(pwd)")"
9+
#GOOS=linux CGO_ENABLED=0 \
10+
# go build \
11+
# -gcflags "all=-trimpath=${WD}" \
12+
# -asmflags "all=-trimpath=${WD}" \
13+
# -o images/scorecard-test/scorecard-test \
14+
# images/scorecard-test/cmd/test/main.go
15+
16+
# Build base image
17+
pushd images/scorecard-test
18+
docker build -t "$1" .
19+
# If using a kind cluster, load the image into all nodes.
20+
load_image_if_kind "$1"
21+
popd

images/scorecard-test/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Base image
2+
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
3+
4+
ENV TEST=/usr/local/bin/scorecard-test \
5+
USER_UID=1001 \
6+
USER_NAME=test
7+
8+
# TODO install test binary
9+
# COPY scorecard-test ${TEST}
10+
11+
COPY bin /usr/local/bin
12+
RUN /usr/local/bin/user_setup
13+
14+
15+
ENTRYPOINT ["/usr/local/bin/entrypoint"]
16+
17+
USER ${USER_UID}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh -e
2+
3+
# This is documented here:
4+
# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
5+
6+
exec ${TEST} $@
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
set -x
3+
4+
# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be)
5+
echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd
6+
7+
mkdir -p "${HOME}"
8+
chown "${USER_UID}:0" "${HOME}"
9+
chmod ug+rwx "${HOME}"
10+
11+
# no need for this script to remain in the image after running
12+
rm "$0"

0 commit comments

Comments
 (0)