-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathContainerfile
More file actions
91 lines (85 loc) · 3.2 KB
/
Copy pathContainerfile
File metadata and controls
91 lines (85 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Builder for Go
# (this is to avoid installing all Golang dependencies to our runner image)
FROM registry.access.redhat.com/ubi10/go-toolset:latest AS builder_go
# Download dependencies based on just these two files to be able to cache the layer
COPY go.mod go.sum ./
RUN go mod download -x
# Copy rest of the source code and build it
COPY . .
RUN make build
# Test executables are OK
RUN ./bin/loadtest --help
RUN ./bin/probetest --help
# Builder for oc and yq
# (this is to avoid installing tar to our runner image)
FROM registry.access.redhat.com/ubi10/ubi:latest AS builder_oc
ARG TARGETARCH
# Pinned versions to avoid pulling unreviewed code from "stable"/"latest" channels
ARG OC_VERSION=4.22.8
ARG YQ_VERSION=v4.53.3
# Download and install oc, try multiple times as this is error prone
RUN attempt=1; \
if [ "$TARGETARCH" = "arm64" ]; then \
ARCH_SUFFIX="-arm64"; \
else \
ARCH_SUFFIX=""; \
fi; \
while true; do \
echo "Attempt $attempt"; \
curl -fSL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OC_VERSION}/openshift-client-linux${ARCH_SUFFIX}.tar.gz -o /tmp/openshift-client-linux.tar.gz && \
tar zxvf /tmp/openshift-client-linux.tar.gz -C /usr/bin/ && \
oc version --client && \
break; \
if [[ $attempt -ge 5 ]]; then \
echo "All attempts failed, giving up" >&2; \
exit 1; \
fi; \
sleep 1; \
let attempt+=1; \
done
# Download yq (https://github.com/mikefarah/yq)
RUN attempt=1; \
YQ_ARCH="${TARGETARCH:-amd64}"; \
while true; do \
echo "Attempt $attempt"; \
curl -fSL "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${YQ_ARCH}" -o /usr/bin/yq && \
chmod +x /usr/bin/yq && \
yq --version && \
break; \
if [[ $attempt -ge 5 ]]; then \
echo "All attempts failed, giving up" >&2; \
exit 1; \
fi; \
sleep 1; \
let attempt+=1; \
done
# Runner
FROM registry.access.redhat.com/ubi10/python-312-minimal:latest
# Include license information required by Red Hat certification
COPY LICENSE /licenses/LICENSE
# Copy loadtest binary from builder container
COPY --from=builder_go /opt/app-root/src/bin/loadtest /usr/bin/
COPY --from=builder_go /opt/app-root/src/bin/probetest /usr/bin/
# Copy OpenShift CLI and yq binaries from builder container
COPY --from=builder_oc /usr/bin/oc /usr/bin/
COPY --from=builder_oc /usr/bin/kubectl /usr/bin/
COPY --from=builder_oc /usr/bin/yq /usr/bin/
# Install internal CA certificate
COPY ci-scripts/config/2022-IT-Root-CA.pem \
/etc/pki/ca-trust/source/anchors/2022-IT-Root-CA.pem
COPY requirements.txt requirements.txt
USER 0
RUN update-ca-trust
# Install dependencies for our python scripts
RUN INSTALL_PKGS="git-core jq tar xz" && \
microdnf -y --setopt=tsflags=nodocs --setopt=install_weak_deps=0 install $INSTALL_PKGS && \
microdnf -y clean all --enablerepo='*'
USER 1001
RUN python3 -m pip install -U pip && \
python3 -m pip install -r requirements.txt
# Install our scripts
COPY ci-scripts/ \
./ci-scripts/
# Test s3-artifacts script is OK
RUN python3 ci-scripts/s3-artifacts.py --help
CMD ["sleep", "5d"]