Skip to content

Commit

Permalink
Fix/centos build (#2509) (#2510)
Browse files Browse the repository at this point in the history
Co-authored-by: payetvin <[email protected]>
(cherry picked from commit c2335ca)
  • Loading branch information
a-zakir authored and h-fournier committed Dec 13, 2024
1 parent 6cb7587 commit 9a3998c
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/centos7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ jobs:
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-cache-centos7-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}
key: vcpkg-cache-centos7-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}

37 changes: 37 additions & 0 deletions docker/AntaresDeps
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM centos:7

ENV LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
DEBIAN_FRONTEND=noninteractive \
VCPKG_ROOT=/vcpkg \
ORTOOLS_DIR=ortools

CMD ["/bin/bash"]

# Install requirements : update repo
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo &&\
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo &&\
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo &&\
yum install -y epel-release &&\
yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils python3 &&\
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo &&\
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo &&\
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

RUN yum update -y
RUN yum install -y epel-release
RUN yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils rpm-build && \
yum install -y devtoolset-11 && \
yum install -y rh-git227-git ccache
RUN yum install -y unzip libuuid-devel wxGTK3-devel
RUN yum install -y python3-pip && python3 -m pip install --upgrade pip && pip3 install pytest numpy pandas

# Install requirements
RUN rm -rf /var/cache/yum

RUN echo "source /opt/rh/devtoolset-11/enable" >> /etc/bashrc
SHELL ["/bin/bash", "--login", "-c"]

# Install CMake
RUN pip3 install cmake==3.28.4

95 changes: 95 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
FROM antaresrte/antaressystemdeps:latest



CMD ["/bin/bash"]

RUN mkdir /workspace

RUN echo "source /opt/rh/devtoolset-11/enable" >> /etc/bashrc
SHELL ["/bin/bash", "--login", "-c"]


RUN mkdir -p /workspace/vcpkg_cache
ARG VCPKG_CACHE_DIR
COPY $VCPKG_CACHE_DIR /workspace/


ARG BRANCH=develop
RUN cd /workspace && \
git clone https://github.com/AntaresSimulatorTeam/Antares_Simulator.git --branch $BRANCH && \
cd Antares_Simulator && \
git submodule update --init vcpkg && ./vcpkg/bootstrap-vcpkg.sh -disableMetrics && \
export VCPKG_ROOT=/workspace/Antares_Simulator/vcpkg





RUN ORTOOLS_TAG=$(cat /workspace/Antares_Simulator/ortools_tag) && \
echo "ORTOOLS_TAG=$ORTOOLS_TAG" && \
URL_ORTOOLS=https://github.com/rte-france/or-tools-rte/releases/download/$ORTOOLS_TAG/ortools_cxx_centos7_static_sirius.zip && \
mkdir -p ortools && cd ortools && \
wget -q -O ortools.zip $URL_ORTOOLS && \
unzip -q ortools.zip && \
rm ortools.zip

WORKDIR /workspace/Antares_Simulator
# Accept build arguments for ccache
ARG CCACHE_DIR
ARG CCACHE_KEY

# Copy ccache directory into the container
COPY ${CCACHE_DIR:-/dev/null} /workspace/.ccache

# Configure ccache environment variables
ENV CCACHE_DIR=/workspace/.ccache
ENV CCACHE_BASEDIR=/workspace
ENV CCACHE_COMPRESS=1
ENV PATH="/usr/lib/ccache:$PATH"

RUN source /opt/rh/devtoolset-11/enable && \
source /opt/rh/rh-git227/enable && \
export VCPKG_BINARY_SOURCES="clear;files,/workspace/vcpkg_cache,readwrite" && \
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_TOOLCHAIN_FILE=/workspace/Antares_Simulator/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DBUILD_TOOLS=ON \
-DBUILD_UI=OFF \
-DCMAKE_PREFIX_PATH=/ortools/install

ARG NPROC=2
RUN source /opt/rh/devtoolset-11/enable && \
source /opt/rh/rh-git227/enable && \
export VCPKG_BINARY_SOURCES="clear;files,/workspace/vcpkg_cache,readwrite" && \
cmake --build _build --config Release -j${NPROC} &&\
ccache -s

#Installer .rpm creation
RUN cd _build && \
cpack -G RPM

#Solver archive creation
RUN cd _build && \
cpack -G RPM

RUN cd _build && \
cmake --install . --prefix install && \
pushd . && \
cd install/bin && \
tar czf ../../antares-solver_centos7.tar.gz antares-solver libsirius_solver.so && \
popd && \
rm -rf install

#.tar.gz creation
RUN cd _build && \
cpack -G TGZ
#mv .rpm and .tar.gz
RUN cd _build && \
mkdir archive && \
mv *.tar.gz archive && \
mv *.rpm archive

0 comments on commit 9a3998c

Please sign in to comment.