-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
58 lines (47 loc) · 1.9 KB
/
Dockerfile
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
FROM registry.access.redhat.com/ubi9/ubi:9.5@sha256:2bae9062eddbbc18e76555972e7026ffe02cef560a0076e6d7f72bed2c05723f AS builder
ARG OCT_REPO=github.com/test-network-function/oct.git
ARG TOKEN
ENV OCT_FOLDER=/usr/oct
ENV OCT_DB_FOLDER=${OCT_FOLDER}/cmd/tnf/fetch/data
# Install dependencies
RUN yum install -y gcc git jq make wget
# Install Go binary and set the PATH
ENV \
GO_DL_URL=https://golang.org/dl \
GOPATH=/root/go
ENV GO_BIN_URL_x86_64=${GO_DL_URL}/go1.23.2.linux-amd64.tar.gz
ENV GO_BIN_URL_aarch64=${GO_DL_URL}/go1.23.2.linux-arm64.tar.gz
# Determine the CPU architecture and download the appropriate Go binary
RUN \
if [ "$(uname -m)" = x86_64 ]; then \
wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_x86_64} --quiet \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf ${TEMP_DIR}/go1.23.2.linux-amd64.tar.gz; \
elif [ "$(uname -m)" = aarch64 ]; then \
wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_aarch64} --quiet \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf ${TEMP_DIR}/go1.23.2.linux-arm64.tar.gz; \
else \
echo "CPU architecture is not supported." && exit 1; \
fi
# Add go binary directory to $PATH
ENV PATH=${PATH}:"/usr/local/go/bin":${GOPATH}/"bin"
WORKDIR /root
RUN git clone https://${TOKEN}@$OCT_REPO
WORKDIR /root/oct
RUN make build-oct && \
mkdir -p ${OCT_FOLDER} && \
mkdir -p ${OCT_DB_FOLDER} && \
cp oct ${OCT_FOLDER}
RUN ./oct fetch --operator --container --helm && \
cp -a cmd/tnf/fetch/data/* ${OCT_DB_FOLDER} && \
cp scripts/run.sh ${OCT_FOLDER} && \
chmod -R 777 ${OCT_DB_FOLDER}
# Copy the oct folder to a new minimal flattened image to reduce size.
# It should also hide the pull token.
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest@sha256:d85040b6e3ed3628a89683f51a38c709185efc3fb552db2ad1b9180f2a6c38be
ENV OCT_FOLDER=/usr/oct
COPY --from=builder ${OCT_FOLDER} ${OCT_FOLDER}
WORKDIR ${OCT_FOLDER}
ENV SHELL=/bin/bash
CMD ["./run.sh"]