forked from backube/volsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.volsync-custom-scorecard-tests
92 lines (70 loc) · 3.15 KB
/
Dockerfile.volsync-custom-scorecard-tests
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
92
# Build the volsync-custom-scorecard-tests binary
FROM golang:1.20 as builder
# Copy the go source
COPY ./custom-scorecard-tests/. /workspace/
WORKDIR /workspace
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
ARG version_arg="(unknown)"
# Build the volsync-custom-scorecard-tests binary
RUN GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o volsync-custom-scorecard-tests -ldflags "-X=main.version=${version_arg}" main.go
# Build the kubectl-volsync cli
COPY ./kubectl-volsync/. /workspace-cli/kubectl-volsync/
COPY ./go.mod /workspace-cli/go.mod
COPY ./go.sum /workspace-cli/go.sum
COPY ./api/ /workspace-cli/api/
WORKDIR /workspace-cli
RUN GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o bin/kubectl-volsync -ldflags "-X=github.com/backube/volsync/kubectl-volsync/cmd.volsyncVersion=${version_arg}" ./kubectl-volsync/main.go
# Build final container
FROM registry.access.redhat.com/ubi9/python-311
USER root
RUN dnf --refresh update -y && \
dnf --nodocs --setopt=install_weak_deps=0 install -y \
bash \
python \
python3-pip \
tar \
gzip \
&& dnf clean all
ENV HOME=/opt/volsync-custom-scorecard-tests \
USER_NAME=volsync-custom-scorecard-tests \
USER_UID=1001
RUN echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd
WORKDIR ${HOME}
COPY --from=builder /workspace/volsync-custom-scorecard-tests /usr/local/bin/volsync-custom-scorecard-tests
COPY --from=builder /workspace-cli/bin/kubectl-volsync ./bin/kubectl-volsync
# Copy e2e tests into the container
COPY ./test-e2e/. ./test-e2e
COPY ./hack/ensure-default-csi.sh .
COPY ./hack/run-minio.sh .
# Copy in auto-retry script
COPY ./.ci-scripts/retry.sh .
ARG pipenv_version_arg
ARG helm_version_arg
ARG kubectl_version_arg
RUN cd test-e2e && \
../retry.sh python -m pip install --upgrade pip && \
../retry.sh pip install --upgrade pipenv=="${pipenv_version_arg}" && \
../retry.sh pipenv sync && \
../retry.sh pipenv run ansible-galaxy install -r requirements.yml
# Install helm & kubectl
RUN curl -sSL "https://get.helm.sh/helm-${helm_version_arg}-linux-amd64.tar.gz" | tar xzf - -C /usr/local/bin/ --strip-components=1 --wildcards '*/helm' && \
chmod 0755 /usr/local/bin/helm && \
cd /usr/local/bin && curl -LO "https://dl.k8s.io/release/${kubectl_version_arg}/bin/linux/amd64/kubectl" && \
chmod 0755 /usr/local/bin/kubectl
ARG builddate_arg="(unknown)"
ARG version_arg="(unknown)"
ENV builddate="${builddate_arg}"
ENV version="${version_arg}"
LABEL org.label-schema.build-date="${builddate}" \
org.label-schema.description="custom scorecard tests for VolSync" \
org.label-schema.license="AGPL v3" \
org.label-schema.name="volsync-custom-scorecard-tests" \
org.label-schema.schema-version="1.0" \
org.label-schema.vcs-ref="${version}" \
org.label-schema.vcs-url="https://github.com/backube/volsync" \
org.label-schema.vendor="Backube" \
org.label-schema.version="${version}"
ENTRYPOINT ["/usr/local/bin/volsync-custom-scorecard-tests"]
USER ${USER_UID}