Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Make the Dockerfile platform-independent #64

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 4 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
FROM registry.access.redhat.com/ubi8/ubi:8.9-1107.1706791207 AS build
FROM golang:1.21.6-alpine AS builder
ENV TNF_SRC_DIR=/usr/tnf

# Install dependencies
RUN \
mkdir ${TNF_SRC_DIR} \
&& dnf update --assumeyes --disableplugin=subscription-manager \
&& dnf install --assumeyes --disableplugin=subscription-manager \
gcc \
git \
jq \
cmake \
wget \
&& dnf clean all --assumeyes --disableplugin=subscription-manager \
&& rm -rf /var/cache/yum

# Install Go binary and set the PATH
ENV \
GO_DL_URL=https://golang.org/dl \
GO_BIN_TAR=go1.21.6.linux-amd64.tar.gz \
GOPATH=/root/go
ENV GO_BIN_URL_x86_64=${GO_DL_URL}/${GO_BIN_TAR}
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}/${GO_BIN_TAR}; \
else \
echo "CPU architecture is not supported." && exit 1; \
fi
ENV PATH=${PATH}:"/usr/local/go/bin":${GOPATH}/"bin"

# Build the application
RUN apk add --no-cache make~=4.4.1
COPY . ${TNF_SRC_DIR}
WORKDIR ${TNF_SRC_DIR}
RUN make build

# Copy the app into an empty ubi minimal image.
FROM registry.access.redhat.com/ubi8-minimal:8.9-1108.1706691034
ENV TNF_SRC_DIR=/usr/tnf
RUN mkdir ${TNF_SRC_DIR}

COPY --from=build ${TNF_SRC_DIR}/schemas ${TNF_SRC_DIR}/schemas
COPY --from=build ${TNF_SRC_DIR}/gradetool ${TNF_SRC_DIR}

COPY --from=builder ${TNF_SRC_DIR}/schemas ${TNF_SRC_DIR}/schemas
COPY --from=builder ${TNF_SRC_DIR}/gradetool ${TNF_SRC_DIR}
WORKDIR ${TNF_SRC_DIR}
ENTRYPOINT ["./gradetool"]
Loading