-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathe2e-tests.Containerfile
More file actions
60 lines (43 loc) · 2.01 KB
/
e2e-tests.Containerfile
File metadata and controls
60 lines (43 loc) · 2.01 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
# Extract CLI tools from their official images
FROM quay.io/hypershift/hypershift-operator:latest as hypershift-cli
FROM quay.io/openshift/origin-cli:latest as oc-cli
# Main test image
FROM registry.access.redhat.com/ubi10/go-toolset:1.25 AS tester
USER root
WORKDIR /workspace
# Install required system tools
RUN dnf install -y \
openssl \
openssh-clients \
&& dnf clean all
# Install Helm
RUN curl -L https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Copy CLI tools from their official images
COPY --from=hypershift-cli /usr/bin/hypershift /usr/bin/hypershift
COPY --from=oc-cli /usr/bin/oc /usr/bin/oc
# Create kubectl symlink (oc provides kubectl functionality)
RUN ln -s /usr/bin/oc /usr/bin/kubectl
# Copy Go module files (required for go test to resolve module imports)
COPY --chown=1001:0 go.mod go.sum ./
# Copy vendor directory (contains all dependencies including ginkgo/gomega test frameworks and NVIDIA doca-platform for CRD generation)
COPY --chown=1001:0 vendor/ ./vendor/
# Copy API definitions (tests import api/v1alpha1 types)
COPY --chown=1001:0 api/ ./api/
# Copy config directory (contains CRD manifests that helm chart symlinks reference)
COPY --chown=1001:0 config/ ./config/
# Copy Makefile (used to run e2e targets like e2e-deploy-hypershift, e2e-install-dpf-crds)
COPY --chown=1001:0 Makefile ./
# Build controller-gen inside the container (ensures correct OS/arch for CRD generation)
RUN make controller-gen
# Copy all test code (e2e tests, utils, scripts)
COPY --chown=1001:0 test/ ./test/
# Copy helm chart (used to deploy operator during tests)
COPY --chown=1001:0 helm/ ./helm/
# Create directory for generated CRDs (controller-gen writes here during test setup)
RUN mkdir -p test/e2e/testdata/crds
# Set OpenShift-compatible permissions on entire workspace (arbitrary UID, group 0)
# This allows the container to run with any UID in OpenShift (always group 0)
RUN chgrp -R 0 /workspace && \
chmod -R g=u /workspace
# Set user to non-root for running tests
USER 1001