From 4d1f351aa443a2958111ca723c82b14886a70753 Mon Sep 17 00:00:00 2001 From: Gautier Bureau Date: Thu, 4 Jul 2024 15:31:36 +0200 Subject: [PATCH] #106 Add gcc11 image for distribution. Signed-off-by: Gautier Bureau --- .github/workflows/distribution-gcc11.yml | 28 ++++++++ Distribution-gcc11/.dockerignore | 1 + Distribution-gcc11/Dockerfile | 72 +++++++++++++++++++ Distribution-gcc11/build_docker_image.sh | 54 ++++++++++++++ Distribution-gcc11/connect_to_container.sh | 59 +++++++++++++++ .../connect_to_container_mine.sh | 62 ++++++++++++++++ Distribution-gcc11/create_container.sh | 68 ++++++++++++++++++ Distribution-gcc11/create_container_mine.sh | 70 ++++++++++++++++++ Distribution-gcc11/delete_container.sh | 45 ++++++++++++ Distribution-gcc11/delete_image.sh | 45 ++++++++++++ 10 files changed, 504 insertions(+) create mode 100644 .github/workflows/distribution-gcc11.yml create mode 100644 Distribution-gcc11/.dockerignore create mode 100644 Distribution-gcc11/Dockerfile create mode 100755 Distribution-gcc11/build_docker_image.sh create mode 100755 Distribution-gcc11/connect_to_container.sh create mode 100755 Distribution-gcc11/connect_to_container_mine.sh create mode 100755 Distribution-gcc11/create_container.sh create mode 100755 Distribution-gcc11/create_container_mine.sh create mode 100755 Distribution-gcc11/delete_container.sh create mode 100755 Distribution-gcc11/delete_image.sh diff --git a/.github/workflows/distribution-gcc11.yml b/.github/workflows/distribution-gcc11.yml new file mode 100644 index 0000000..be7d4dd --- /dev/null +++ b/.github/workflows/distribution-gcc11.yml @@ -0,0 +1,28 @@ +name: Distribution gcc11 Image + +on: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses : actions/checkout@v4 + - name: docker login + env: + DOCKER_USER: ${{secrets.DOCKER_USER}} + DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} + run: | + docker login -u $DOCKER_USER -p $DOCKER_PASSWORD + + - name: Build the Docker image + run: | + cd Distribution-gcc11 + docker build . --file Dockerfile --tag dynawo/dynawo-distribution-gcc11:latest + + - name: Docker Push + run: docker push dynawo/dynawo-distribution-gcc11 diff --git a/Distribution-gcc11/.dockerignore b/Distribution-gcc11/.dockerignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/Distribution-gcc11/.dockerignore @@ -0,0 +1 @@ +* diff --git a/Distribution-gcc11/Dockerfile b/Distribution-gcc11/Dockerfile new file mode 100644 index 0000000..f94ad60 --- /dev/null +++ b/Distribution-gcc11/Dockerfile @@ -0,0 +1,72 @@ +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +FROM ubuntu:22.04 +LABEL maintainer Gautier Bureau "gautier.bureau@rte-france.com" + +ENV TZ=Europe/Paris \ +DEBIAN_FRONTEND=noninteractive + +RUN apt update \ +&& apt upgrade -y -q \ +&& apt install -y git \ + gcc \ + g++ \ + gfortran \ + autoconf \ + pkgconf \ + automake \ + make \ + libtool \ + cmake \ + hwloc \ + openjdk-8-jdk \ + libblas-dev \ + liblpsolve55-dev \ + libarchive-dev \ + doxygen \ + doxygen-latex \ + liblapack-dev \ + libexpat1-dev \ + libsqlite3-dev \ + zlib1g-dev \ + gettext \ + patch \ + clang \ + python3-pip \ + libncurses5-dev \ + libreadline-dev \ + libdigest-perl-md5-perl \ + unzip \ + gcovr \ + lcov \ + libboost-all-dev \ + lsb-release \ + libxml2-utils \ + python3-lxml \ + python3-psutil \ + wget \ + libcurl4-openssl-dev \ + rsync \ + libopenblas-openmp-dev \ + qtbase5-dev \ + qtchooser \ + qt5-qmake \ + qtbase5-dev-tools \ + vim \ + curl \ + wget \ + ninja-build \ + gdb \ + gdbserver \ + sudo \ +&& apt clean \ +&& rm -rf /var/lib/apt/lists/* + +CMD ["/bin/bash"] diff --git a/Distribution-gcc11/build_docker_image.sh b/Distribution-gcc11/build_docker_image.sh new file mode 100755 index 0000000..a71ccdf --- /dev/null +++ b/Distribution-gcc11/build_docker_image.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to create a Dynawo image. + + where OPTIONS can be one of the following: + --name (-n) myname image name created (default: dynawo-distribution-gcc11) + --help (-h) print this message. +" +} + +build_image() { + if ! `image_exists $image_name`; then + docker build --force-rm -t $image_name --no-cache=true . + else + echo "Image $image_name already exists. You can delete it with: ./delete_image.sh --name $image_name" + exit 1 + fi +} + +image_name=dynawo-distribution-gcc11 + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --name|-n) + image_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +build_image diff --git a/Distribution-gcc11/connect_to_container.sh b/Distribution-gcc11/connect_to_container.sh new file mode 100755 index 0000000..c1d0266 --- /dev/null +++ b/Distribution-gcc11/connect_to_container.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to connect to a Dynawo container. + + where OPTIONS can be one of the following: + --name (-n) myname container name to connect to (default: dynawo-distribution-gcc11) + --help (-h) print this message. +" +} + +connect_to_container() { + if `container_exists $container_name`; then + if ! `container_is_running $container_name`; then + docker start $container_name + fi + docker exec -it $container_name bash + else + echo "You specified a container $container_name that is not created." + echo "List of available containers:" + for name in `docker ps -a --format "{{.Names}}"`; do echo " $name"; done + exit 1 + fi +} + +container_name=dynawo-distribution-gcc11 + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --name|-n) + container_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +connect_to_container diff --git a/Distribution-gcc11/connect_to_container_mine.sh b/Distribution-gcc11/connect_to_container_mine.sh new file mode 100755 index 0000000..a964e26 --- /dev/null +++ b/Distribution-gcc11/connect_to_container_mine.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to connect to a Dynawo container. + + where OPTIONS can be one of the following: + --name (-n) myname container name to connect to (default: dynawo-distribution) + --help (-h) print this message. +" +} + +connect_to_container() { + if `container_exists $container_name`; then + if ! `container_is_running $container_name`; then + docker start $container_name + fi + docker exec -u root $container_name groupadd "$(id -u -n)" -g "$(id -g)" + docker exec -u root $container_name adduser "$(id -u -n)" -u "$(id -u)" -g "$(id -g)" + docker exec -u root $container_name chown -R "$(id -u -n)":"$(id -u -n)" /home/dynawo_distribution/ + docker exec -it -u "$(id -u):$(id -g)" $container_name bash + else + echo "You specified a container $container_name that is not created." + echo "List of available containers:" + for name in `docker ps -a --format "{{.Names}}"`; do echo " $name"; done + exit 1 + fi +} + +container_name=dynawo-distribution + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --name|-n) + container_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +connect_to_container diff --git a/Distribution-gcc11/create_container.sh b/Distribution-gcc11/create_container.sh new file mode 100755 index 0000000..8fdb41e --- /dev/null +++ b/Distribution-gcc11/create_container.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to create a Dynawo container. + + where OPTIONS can be one of the following: + --container-name (-n) mycontainer container name created (default: dynawo-distribution-gcc11) + --image-name (-i) myimage image name (default: dynawo-distribution-gcc11) + --help (-h) print this message. +" +} + +create_container() { + if ! `container_exists $container_name`; then + if `image_exists $image_name`; then + docker run -it -d --name=$container_name \ + $image_name bash + else + echo "You specified an image name that is not existing." + echo "List of available images:" + for name in `docker images --format "{{.Repository}}" | sort | uniq`; do echo " $name"; done + exit 1 + fi + else + echo "Container $container_name already exists. You can delete it with: ./delete_container.sh --name $container_name" + exit 1 + fi +} + +container_name=dynawo-distribution-gcc11 +image_name=dynawo-distribution-gcc11 + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --container-name|-n) + container_name=$2 + shift 2 + ;; + --image-name|-i) + image_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +create_container diff --git a/Distribution-gcc11/create_container_mine.sh b/Distribution-gcc11/create_container_mine.sh new file mode 100755 index 0000000..0d8f838 --- /dev/null +++ b/Distribution-gcc11/create_container_mine.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to create a Dynawo container. + + where OPTIONS can be one of the following: + --container-name (-n) mycontainer container name created (default: dynawo-distribution) + --image-name (-i) myimage image name (default: dynawo-distribution) + --help (-h) print this message. +" +} + +create_container() { + if ! `container_exists $container_name`; then + if `image_exists $image_name`; then + docker run -it -d -u "$(id -u):$(id -g)" --name=$container_name \ + -v $(pwd):/fedora \ + -w /fedora \ + $image_name bash + else + echo "You specified an image name that is not existing." + echo "List of available images:" + for name in `docker images --format "{{.Repository}}" | sort | uniq`; do echo " $name"; done + exit 1 + fi + else + echo "Container $container_name already exists. You can delete it with: ./delete_container.sh --name $container_name" + exit 1 + fi +} + +container_name=dynawo-distribution +image_name=dynawo-distribution + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --container-name|-n) + container_name=$2 + shift 2 + ;; + --image-name|-i) + image_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +create_container diff --git a/Distribution-gcc11/delete_container.sh b/Distribution-gcc11/delete_container.sh new file mode 100755 index 0000000..9a3f827 --- /dev/null +++ b/Distribution-gcc11/delete_container.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to delete a Dynawo container. + + where OPTIONS can be one of the following: + --name -(n) myname container name to delete (default: dynawo-distribution-gcc11) + --help (-h) print this message. +" +} + +container_name=dynawo-distribution-gcc11 + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --name|-n) + container_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +delete_container $container_name diff --git a/Distribution-gcc11/delete_image.sh b/Distribution-gcc11/delete_image.sh new file mode 100755 index 0000000..da495d9 --- /dev/null +++ b/Distribution-gcc11/delete_image.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Copyright (c) 2024, RTE (http://www.rte-france.com) +# See AUTHORS.txt +# All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# SPDX-License-Identifier: MPL-2.0 +# +# This file is part of Dynawo, an hybrid C++/Modelica open source time domain simulation tool for power systems. +# + +source ../Helper/helper.sh + +usage() { + echo -e "Usage: `basename $0` [OPTIONS]\tprogram to delete a Dynawo image. + + where OPTIONS can be one of the following: + --name (-n) myname image name to delete (default: dynawo-distribution-gcc11) + --help (-h) print this message. +" +} + +image_name=dynawo-distribution-gcc11 + +while (($#)); do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --name|-n) + image_name=$2 + shift 2 + ;; + *) + echo "$1: invalid option." + usage + exit 1 + ;; + esac +done + +delete_image $image_name