From ae9f10d3dd45354643ea3415cc0a065d4dd960d1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Keck <jean-baptiste.keck@univ-grenoble-alpes.fr> Date: Sat, 24 Sep 2022 12:18:09 +0200 Subject: [PATCH] test with ci bat utility scripts on windows [ci skip] --- ci/utils/build_docker_image.bat | 7 +++++++ ci/utils/pull_docker_image.bat | 27 +++++++++++++++++++++++++++ ci/utils/push_docker_image.bat | 27 +++++++++++++++++++++++++++ ci/utils/run_docker_image.bat | 8 ++++++++ 4 files changed, 69 insertions(+) create mode 100755 ci/utils/build_docker_image.bat create mode 100755 ci/utils/pull_docker_image.bat create mode 100755 ci/utils/push_docker_image.bat create mode 100755 ci/utils/run_docker_image.bat diff --git a/ci/utils/build_docker_image.bat b/ci/utils/build_docker_image.bat new file mode 100755 index 000000000..d0dce81d1 --- /dev/null +++ b/ci/utils/build_docker_image.bat @@ -0,0 +1,7 @@ +pushd %~dp0 +set SCRIPT_DIR=%CD% +popd +set NTHREADS=%NUMBER_OF_PROCESSORS% +set HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' +if "%~1" NEQ "" set DOCKER_IMAGE_TAG="%~1" else set DOCKER_IMAGE_TAG="jammy" +docker "build" "--rm=true" "--build-arg" "NTHREADS=%NTHREADS%" "-t" "%HYSOP_REGISTRY_URL%\particle_methods\hysop:%DOCKER_IMAGE_TAG%" "-f" "%SCRIPT_DIR%\..\docker_images\ubuntu\%DOCKER_IMAGE_TAG%\Dockerfile" "%SCRIPT_DIR%\..\.." diff --git a/ci/utils/pull_docker_image.bat b/ci/utils/pull_docker_image.bat new file mode 100755 index 000000000..46d12f5a6 --- /dev/null +++ b/ci/utils/pull_docker_image.bat @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +## +## Copyright (C) HySoP 2011-2022 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +set -euf -o pipefail +DOCKER_IMAGE_TAG=${1:-jammy} +HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' +docker logout +if [[ -z "${HYSOP_REGISTRY_USERNAME}" ]] || [[ -z "${HYSOP_REGISTRY_TOKEN}" ]]; then + docker login "${HYSOP_REGISTRY_URL}" +else + echo "${HYSOP_REGISTRY_TOKEN}" | docker login "${HYSOP_REGISTRY_URL}" --username "${HYSOP_REGISTRY_USERNAME}" --password-stdin +fi +docker pull "${HYSOP_REGISTRY_URL}/particle_methods/hysop:${DOCKER_IMAGE_TAG}" +docker logout diff --git a/ci/utils/push_docker_image.bat b/ci/utils/push_docker_image.bat new file mode 100755 index 000000000..c4e9a855e --- /dev/null +++ b/ci/utils/push_docker_image.bat @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +## +## Copyright (C) HySoP 2011-2022 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +set -euf -o pipefail +DOCKER_IMAGE_TAG=${1:-jammy} +HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' +docker logout +if [[ -z "${HYSOP_REGISTRY_USERNAME}" ]] || [[ -z "${HYSOP_REGISTRY_TOKEN}" ]]; then + docker login "${HYSOP_REGISTRY_URL}" +else + echo "${HYSOP_REGISTRY_TOKEN}" | docker login "${HYSOP_REGISTRY_URL}" --username "${HYSOP_REGISTRY_USERNAME}" --password-stdin +fi +docker push "${HYSOP_REGISTRY_URL}/particle_methods/hysop:${DOCKER_IMAGE_TAG}" +docker logout diff --git a/ci/utils/run_docker_image.bat b/ci/utils/run_docker_image.bat new file mode 100755 index 000000000..c0d6255ea --- /dev/null +++ b/ci/utils/run_docker_image.bat @@ -0,0 +1,8 @@ +SET DOCKER_IMAGE_TAG=%1:-jammy% +SET HYSOP_REGISTRY_URL='gricad-registry.univ-grenoble-alpes.fr' +IF [[ "%DOCKER_IMAGE_TAG%" == "*_cuda" "]]" ( + SET EXTRA_ARGS=--gpus all +) ELSE ( + SET EXTRA_ARGS= +) +docker "run" "--cap-add=SYS_PTRACE" "%EXTRA_ARGS%" "-it" "-v" "%SCRIPT_DIR%\..\%CD%.:\hysop:ro" "%HYSOP_REGISTRY_URL%\particle_methods\hysop:%DOCKER_IMAGE_TAG%" -- GitLab