-
Notifications
You must be signed in to change notification settings - Fork 6
/
rpmbuild.Dockerfile
47 lines (37 loc) · 1.66 KB
/
rpmbuild.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
FROM almalinux:9 as build_env
RUN yum install -y \
epel-release \
curl-minimal \
rpm-build \
yum-utils \
&& yum clean all
RUN ln -s cmake3 /usr/bin/cmake
# install rustup for the cargo tool and compile toolchain
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh /dev/stdin -y --default-toolchain=1.82.0
ENV PATH="${PATH}:/root/.cargo/bin"
# install protobuf compiler (protoc command)
ENV PB_REL="https://github.com/protocolbuffers/protobuf/releases"
RUN curl --proto '=https' --tlsv1.2 -sSfLO ${PB_REL}/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip && \
unzip -o protoc-3.15.8-linux-x86_64.zip -d "/usr" && \
rm protoc-3.15.8-linux-x86_64.zip
RUN chmod +x /usr/bin/protoc
# install flatbuffers compiler (flatc command)
ENV FB_REL=https://github.com/google/flatbuffers/releases/
RUN curl --proto '=https' --tlsv1.2 -sSfL ${FB_REL}/download/v23.5.26/Linux.flatc.binary.g++-10.zip | funzip > /usr/bin/flatc
RUN chmod +x /usr/bin/flatc
ENV PATH $PATH:/root/.cargo/bin
RUN mkdir -p /root/rpmbuild/{SOURCES,SPECS,RPMS,SRPMS}
FROM build_env as rpm_build
ARG VERSION
ARG APP
COPY ${APP}.spec /root/rpmbuild/SPECS/
ENV VERSION ${VERSION}
ENV APP ${APP}
RUN echo "Building $APP @ $VERSION"
# ensure the current build version matches the one in the rpm
# spec file, or things can go awry
RUN test "$VERSION" == "$(cat /root/rpmbuild/SPECS/$APP.spec | grep Version | cut -d ' ' -f 2)"
RUN yum-builddep -y /root/rpmbuild/SPECS/$APP.spec && yum clean all
COPY . /source/$APP-$VERSION
RUN tar -C /source -czvf /root/rpmbuild/SOURCES/v$VERSION.tar.gz .
ENTRYPOINT ["sh", "-c", "rpmbuild -ba /root/rpmbuild/SPECS/$APP.spec && chmod 0777 -R /root/rpmbuild/RPMS"]