-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDockerfile.mrvlCPAgent.rhel
More file actions
77 lines (67 loc) · 2.99 KB
/
Copy pathDockerfile.mrvlCPAgent.rhel
File metadata and controls
77 lines (67 loc) · 2.99 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
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS stage1
ARG TARGETOS
ARG TARGETARCH
RUN dnf update -y && dnf install gawk gcc g++ libconfig-devel -y
WORKDIR /workspace
COPY . .
RUN \
set -x && \
mkdir -p /cpagent-bin/ && \
\
if [ "$TARGETARCH" = "arm64" ] ; then \
\
export OCTEP_PATH="/workspace/pcie_ep_octeon_target/target/libs/octep_cp_lib" && \
\
\
ln -nfs internal/daemon/vendor-specific-plugins/marvell/vendor/pcie_ep_octeon_target.25.03.0/ /workspace/pcie_ep_octeon_target && \
\
cd "/workspace/pcie_ep_octeon_target/target/libs/octep_cp_lib" && \
make CFLAGS="-DUSE_PEM_AND_DPI_PF=1" && \
\
cd "/workspace/pcie_ep_octeon_target/target/apps/octep_cp_agent" && \
make CFLAGS="$(pkg-config --cflags libconfig) -I$OCTEP_PATH/include" \
LDFLAGS="$(pkg-config --libs libconfig) -L$OCTEP_PATH/bin/lib" && \
\
cp bin/bin/octep_cp_agent /cpagent-bin/octep_cp_agent.25.03.0 && \
\
\
ln -nfs internal/daemon/vendor-specific-plugins/marvell/vendor/pcie_ep_octeon_target/ /workspace/pcie_ep_octeon_target && \
\
cd "/workspace/pcie_ep_octeon_target/target/libs/octep_cp_lib" && \
make CFLAGS="-DUSE_PEM_AND_DPI_PF=1" && \
\
cd "/workspace/pcie_ep_octeon_target/target/apps/octep_cp_agent" && \
make CFLAGS="$(pkg-config --cflags libconfig) -I$OCTEP_PATH/include" \
LDFLAGS="$(pkg-config --libs libconfig) -L$OCTEP_PATH/bin/lib" && \
\
cp bin/bin/octep_cp_agent /cpagent-bin/ && \
\
cp cn106xx.cfg /cpagent-bin/ && \
\
echo "build completed" ; \
fi
# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
# Due to https://github.com/golang/go/issues/70329 cross-compilation hangs at times.
# As a temporary workaround, we can try specifying GOMAXPROCS=2 to relieve this issue
WORKDIR /workspace
RUN GOMAXPROCS=2 CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -o /cpagent-bin/cp-agent-run internal/daemon/vendor-specific-plugins/marvell/cp-agent/cp-agent-run.go
# Use distroless as minimal base image to package the Marvell CP agent binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
COPY --from=stage1 /cpagent-bin/ /usr/bin/
RUN yum update -y \
&& yum install -y \
net-tools \
kmod \
pciutils \
iputils \
iproute \
libconfig \
&& yum clean all \
&& rm -rf /var/cache/dnf
USER 0
ENTRYPOINT ["/usr/bin/cp-agent-run"]