-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.podvm_builder.rhel
69 lines (57 loc) · 2.99 KB
/
Dockerfile.podvm_builder.rhel
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
# syntax=docker/dockerfile:1.5-labs
# Copyright Confidential Containers Contributors
#
# SPDX-License-Identifier: Apache-2.0
#
# Creates a builder container image that should be used to build the Pod VM
# disk inside a container.
#
FROM registry.access.redhat.com/ubi9/ubi:9.2
ARG ARCH
ARG PACKER_VERSION
ARG GO_VERSION
ARG PROTOC_VERSION
ARG RUST_VERSION
ARG ORG_ID
ARG ACTIVATION_KEY
ARG YQ_VERSION
ENV SMDEV_CONTAINER_OFF=1
ENV ARCH ${ARCH}
# This registering RHEL when building on an unsubscribed system
# If you are running a UBI container on a registered and subscribed RHEL host, the main RHEL Server repository is enabled inside the standard UBI container
RUN if [[ -n "${ACTIVATION_KEY}" && -n "${ORG_ID}" ]]; then \
subscription-manager register --org=${ORG_ID} --activationkey=${ACTIVATION_KEY}; \
fi
RUN subscription-manager repos --enable codeready-builder-for-rhel-9-${ARCH}-rpms; \
dnf groupinstall -y 'Development Tools'; \
dnf install -y yum-utils gnupg git --allowerasing curl pkg-config clang perl libseccomp-devel gpgme-devel \
device-mapper-devel qemu-kvm unzip wget libassuan-devel genisoimage cloud-utils-growpart cloud-init;
ADD --checksum=${YQ_CHECKSUM} https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH/x86_64/amd64} /usr/local/bin/yq
RUN chmod a+x /usr/local/bin/yq && \
curl https://dl.google.com/go/go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz -o go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz && \
rm -f go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz
ENV PATH="/usr/local/go/bin:${PATH}"
# Install packer. Packer doesn't does not have prebuilt s390x arch binaries above Packer version 0.1.5
RUN if [ "${ARCH}" == "s390x" ]; then \
git clone --depth 1 --single-branch https://github.com/hashicorp/packer.git -b ${PACKER_VERSION}; \
cd packer; \
sed -i -- "s/ALL_XC_ARCH=.*/ALL_XC_ARCH=\"${ARCH}\"/g" scripts/build.sh; \
sed -i -- "s/ALL_XC_OS=.*/ALL_XC_OS=\"Linux\"/g" scripts/build.sh; \
make bin && cp bin/packer /usr/local/bin/; \
cd $OLDPWD; \
else \
yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo && \
dnf install -y packer; \
fi
# set a correspond qemu-system-* named link to qemu-kvm
RUN ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-system-$(uname -m)
# cloud-utils package is not available for rhel.
RUN git clone https://github.com/canonical/cloud-utils
RUN cd cloud-utils && make install
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain "${RUST_VERSION}"
ENV PATH "/root/.cargo/bin:/usr/local/go/bin:$PATH"
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${ARCH/s390x/s390_64}.zip && \
unzip protoc-${PROTOC_VERSION}-linux-${ARCH/s390x/s390_64}.zip -d /usr/local && rm -f protoc-${PROTOC_VERSION}-linux-${ARCH/s390x/s390_64}.zip
WORKDIR /src
ENV GOPATH /src