-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile.local
61 lines (49 loc) · 1.89 KB
/
Dockerfile.local
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
FROM registry.access.redhat.com/ubi9/ubi:9.5 AS builder
ARG OCT_LOCAL_FOLDER
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.3.linux-amd64.tar.gz
ENV GO_BIN_URL_aarch64=${GO_DL_URL}/go1.23.3.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.3.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.3.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 echo "Coyping OCT from local folder ${OCT_LOCAL_FOLDER}"
COPY ${OCT_LOCAL_FOLDER} .
RUN make build-oct && \
mkdir -p ${OCT_FOLDER} && \
mkdir -p ${OCT_DB_FOLDER} && \
ls -la ${OCT_FOLDER} && \
cp oct ${OCT_FOLDER} && \
ls -la ${OCT_FOLDER}/*
RUN ./oct fetch --operator --container --helm && \
ls -laR cmd/tnf/fetch/data/* && \
cp -a cmd/tnf/fetch/data/* ${OCT_DB_FOLDER} && \
cp scripts/run.sh ${OCT_FOLDER} && \
chmod -R 777 ${OCT_DB_FOLDER}
# Copy the state into a new flattened image to reduce (layers) size.
# It should also hide the pull token.
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
ENV OCT_FOLDER=/usr/oct
COPY --from=builder ${OCT_FOLDER} ${OCT_FOLDER}
WORKDIR ${OCT_FOLDER}
ENV SHELL=/bin/bash
CMD ["./run.sh"]