From ecb4795fa095cab8720e275c40c67a818e42ea4d Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Mon, 23 Jan 2023 14:59:26 +0100 Subject: [PATCH 01/18] DBG: self-hosted runner --- .github/workflows/ci_cd.yml | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index b7469e05e2..d61fdca265 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -12,7 +12,7 @@ env: LIBRARY_NAME: 'ansys-stk-core' LIBRARY_NAMESPACE: 'ansys.stk.core' DOCUMENTATION_CNAME: 'stk.docs.pyansys.com' - + STK_DOCKER_IMAGE_NAME: 'ansys/stk/stk-python' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -73,18 +73,12 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} tests: - name: "Test Python ${{ matrix.cfg.python-version }} in ${{ matrix.os }} " - runs-on: ${{ matrix.os }} - needs: code-style + name: "Test using Python ${{ matrix.python }}" + runs-on: [self-hosted, pystk] + #needs: code-style strategy: matrix: - os: [windows-latest, ubuntu-latest] - cfg: - - {python-version: '3.7', extra-args: ''} - - {python-version: '3.8', extra-args: ''} - - {python-version: '3.9', extra-args: ''} - - {python-version: '3.10', extra-args: '--cov=ansys.stk --cov-report=term --cov-report=html:.cov/html'} - + python: ['3.7', '3.8', '3.9', '3.10'] fail-fast: false steps: @@ -94,13 +88,21 @@ jobs: python-version: ${{ matrix.cfg.python-version }} pytest-extra-args: ${{ matrix.cfg.extra-args }} - - name: "Upload coverage results" - uses: actions/upload-artifact@v3 - if: matrix.cfg.python-version == env.MAIN_PYTHON_VERSION && matrix.os == 'ubuntu-latest' - with: - name: coverage-html - path: .cov/html - retention-days: 7 + - name: "Show the project structure" + run: | + ls -R + + - name: "Start the STK container with Python ${{ matrix.python }}" + run: | + echo "${{ env.STK_DOCKER_IMAGE_NAME }}-${{ matrix.python }}" + + # - name: "Upload coverage results" + # uses: actions/upload-artifact@v3 + # if: matrix.python == env.MAIN_PYTHON_VERSION + # with: + # name: coverage-html + # path: .cov/html + # retention-days: 7 build-library: name: "Build library artifacts" From bb355e32682a5f70e29e9f11de496accdc906456 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 1 Mar 2023 15:53:59 +0100 Subject: [PATCH 02/18] MAINT: ignore any 'distributions/' dir --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 852dd37586..4d65aa93bc 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,6 @@ cython_debug/ #.idea/ # End of https://www.toptal.com/developers/gitignore/api/python + +# Ignore any distributions directory to prevent accidental publications +distributions/ From aff188954fba5e3493ea965a90126f1089c21224 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 1 Mar 2023 15:58:59 +0100 Subject: [PATCH 03/18] FEAT: add 'stk-engine' docker utilities --- docker/linux/stk-engine/Dockerfile | 50 ++++++++++++++++++++++ docker/linux/stk-engine/docker-compose.yml | 10 +++++ 2 files changed, 60 insertions(+) create mode 100644 docker/linux/stk-engine/Dockerfile create mode 100644 docker/linux/stk-engine/docker-compose.yml diff --git a/docker/linux/stk-engine/Dockerfile b/docker/linux/stk-engine/Dockerfile new file mode 100644 index 0000000000..90c527221c --- /dev/null +++ b/docker/linux/stk-engine/Dockerfile @@ -0,0 +1,50 @@ +ARG baseImage=centos:7 +FROM ${baseImage} AS builder + +# Add the engine packages to the builder stage +COPY distributions/stk*.tgz /tmp/ + +# Unpack engine +RUN set -e; \ + mkdir -p /stk; \ + find /tmp -name stk*.tgz -exec tar -zxf {} --strip-components=1 -C /stk \; + +# Reduce image size by removing unnecessary components +RUN set -e; \ + rm -rf /stk/Data/ExampleScenarios/; \ + rm -rf /stk/Data/HtmlInterface/; \ + rm -rf /stk/Data/HtmlUtilities/; \ + rm -rf /stk/Data/LicAndReg/; \ + rm -rf /stk/Data/Resources/; \ + rm -rf /stk/Data/Viewer/; \ + rm -rf /stk/STKData/VO; \ + rm -rf /stk/licensingclient/linx64/ClientSettings + +# Set the base image for the next stage +FROM ${baseImage} + +LABEL ANSYSLMD_LICENSE_FILE='Specifies the location of the Ansys Licensing Server. The format should be PORT@FQDN. If using a triad of license server, list all servers in the same format separated by semicolons. Required.' + +# Define STK user home directory +ENV STK_USER_HOME=/home/stk + +# Setup non-root STK user +RUN useradd -ms /bin/bash stk + +# Switch to STK user +WORKDIR "${STK_USER_HOME}" +USER stk + +# Copy files from the builder stage +COPY --from=builder --chown=stk /stk/ "${STK_USER_HOME}"/ + +# Configure environment +ENV LD_LIBRARY_PATH="${STK_USER_HOME}/bin" \ + PATH="${STK_USER_HOME}/bin:${PATH}" \ + STK_CONFIG_DIR="${STK_USER_HOME}/config" \ + STK_INSTALL_DIR="${STK_USER_HOME}" + +# Run new user install +RUN stkxnewuser /force /allowOnline=yes + +CMD echo 'STK Engine requires a host application to run. Shutting down this container.' diff --git a/docker/linux/stk-engine/docker-compose.yml b/docker/linux/stk-engine/docker-compose.yml new file mode 100644 index 0000000000..9fb23743ab --- /dev/null +++ b/docker/linux/stk-engine/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.7' +services: + stk: + image: ansys/stk:latest-centos7 + build: + context: . + args: + baseImage: centos:7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE From b5bb48e908952b1246079d20e22a3960227e5f06 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 1 Mar 2023 18:19:20 +0100 Subject: [PATCH 04/18] DBG: self-hosted agent --- .github/workflows/ci_cd.yml | 168 ++++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 73 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d61fdca265..3614148ab4 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -12,7 +12,8 @@ env: LIBRARY_NAME: 'ansys-stk-core' LIBRARY_NAMESPACE: 'ansys.stk.core' DOCUMENTATION_CNAME: 'stk.docs.pyansys.com' - STK_DOCKER_IMAGE_NAME: 'ansys/stk/stk-python' + STK_DOCKER_IMAGE: 'ansys/stk:latest-centos7' + LICENSE_SERVER_PORT: '1055' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -20,81 +21,102 @@ concurrency: jobs: - code-style: - name: "Code style checks" - runs-on: ubuntu-latest - steps: - - name: "Run code style checks" - uses: pyansys/actions/code-style@v4 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - doc-style: - name: "Documentation style checks" - runs-on: ubuntu-latest - steps: - - name: "Run code style checks" - uses: pyansys/actions/doc-style@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - doc-build: - name: "Build project documentation" - runs-on: ubuntu-latest - needs: doc-style - steps: - - name: "Building project documentation" - uses: pyansys/actions/doc-build@v4 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - doc-deploy-dev: - name: "Deploy developers documentation" - runs-on: ubuntu-latest - if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') - needs: doc-build - steps: - - name: "Deploy development documentation" - uses: pyansys/actions/doc-deploy-dev@v4 - with: - cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.GITHUB_TOKEN }} - - doc-deploy-stable: - name: "Deploy stable documentation" - runs-on: ubuntu-latest - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: doc-deploy-dev - steps: - - name: "Deploy stable documentation" - uses: pyansys/actions/doc-deploy-stable@v4 - with: - cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.GITHUB_TOKEN }} + # code-style: + # name: "Code style checks" + # runs-on: ubuntu-latest + # steps: + # - name: "Run code style checks" + # uses: pyansys/actions/code-style@v4 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} + + # doc-style: + # name: "Documentation style checks" + # runs-on: ubuntu-latest + # steps: + # - name: "Run code style checks" + # uses: pyansys/actions/doc-style@v4 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + + # doc-build: + # name: "Build project documentation" + # runs-on: ubuntu-latest + # needs: doc-style + # steps: + # - name: "Building project documentation" + # uses: pyansys/actions/doc-build@v4 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} + + # doc-deploy-dev: + # name: "Deploy developers documentation" + # runs-on: ubuntu-latest + # if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') + # needs: doc-build + # steps: + # - name: "Deploy development documentation" + # uses: pyansys/actions/doc-deploy-dev@v4 + # with: + # cname: ${{ env.DOCUMENTATION_CNAME }} + # token: ${{ secrets.GITHUB_TOKEN }} + + # doc-deploy-stable: + # name: "Deploy stable documentation" + # runs-on: ubuntu-latest + # if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + # needs: doc-deploy-dev + # steps: + # - name: "Deploy stable documentation" + # uses: pyansys/actions/doc-deploy-stable@v4 + # with: + # cname: ${{ env.DOCUMENTATION_CNAME }} + # token: ${{ secrets.GITHUB_TOKEN }} tests: - name: "Test using Python ${{ matrix.python }}" + name: "Tests Python ${{ matrix.python }}" runs-on: [self-hosted, pystk] - #needs: code-style strategy: matrix: - python: ['3.7', '3.8', '3.9', '3.10'] + python: ["3.8", "3.9", "3.10"] fail-fast: false steps: - - name: "Run test suite with pytest" - uses: pyansys/actions/tests-pytest@v4 - with: - python-version: ${{ matrix.cfg.python-version }} - pytest-extra-args: ${{ matrix.cfg.extra-args }} + - name: "Checkout the project" + uses: actions/checkout@v3 + + - name: "Generate the name of the docker image and the container" + run: | + python_image_name=${{ env.STK_DOCKER_IMAGE }}-python${{ matrix.python }} + container_name=stk-py${{ matrix.python }} + echo "STK_PYTHON_IMAGE=$python_image_name" >> $GITHUB_ENV + echo "STK_CONTAINER=$container_name" >> $GITHUB_ENV + + - name: "Start the container from the desired image" + run: | + docker run \ + --detach -it \ + --name ${{ env.STK_CONTAINER }} \ + --env ANSYSLMD_LICENSE_FILE=${{ env.LICENSE_SERVER_PORT }}@${{ secrets.LICENSE_SERVER }} \ + --volume ${PWD}:/home/stk/pystk \ + ${{ env.STK_PYTHON_IMAGE }} + + - name: "Install the project" + run: | + docker exec ${{ env.STK_CONTAINER }} /bin/bash -c \ + "python -m pip install /home/stk/pystk" - - name: "Show the project structure" + - name: "Show the version of the engine" run: | - ls -R + docker exec ${{ env.STK_CONTAINER }} /bin/bash -c \ + "python -c 'from ansys.stk.core.stkengine import STKEngine; print(STKEngine.StartApplication().Version)'" - - name: "Start the STK container with Python ${{ matrix.python }}" + - name: "Stop the container" + if: always() run: | - echo "${{ env.STK_DOCKER_IMAGE_NAME }}-${{ matrix.python }}" + docker stop ${{ env.STK_CONTAINER }} + docker logs ${{ env.STK_CONTAINER }} + docker rm ${{ env.STK_CONTAINER }} # - name: "Upload coverage results" # uses: actions/upload-artifact@v3 @@ -104,15 +126,15 @@ jobs: # path: .cov/html # retention-days: 7 - build-library: - name: "Build library artifacts" - runs-on: ubuntu-latest - needs: [doc-deploy-stable, tests] - steps: - - name: "Build library source and wheel artifacts" - uses: pyansys/actions/build-library@v4 - with: - library-name: ${{ env.LIBRARY_NAME }} + # build-library: + # name: "Build library artifacts" + # runs-on: ubuntu-latest + # needs: [doc-deploy-stable, tests] + # steps: + # - name: "Build library source and wheel artifacts" + # uses: pyansys/actions/build-library@v4 + # with: + # library-name: ${{ env.LIBRARY_NAME }} # release: # name: "Release to private and public PyPI and to GitHub" From e71994bb85aeadc782d353568f55f6d5a253df1b Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 2 Mar 2023 11:57:37 +0100 Subject: [PATCH 05/18] CI: restore workflows --- .github/workflows/ci_cd.yml | 156 ++++++++++++++---------------------- 1 file changed, 62 insertions(+), 94 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 3614148ab4..7f874bf239 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -21,61 +21,63 @@ concurrency: jobs: - # code-style: - # name: "Code style checks" - # runs-on: ubuntu-latest - # steps: - # - name: "Run code style checks" - # uses: pyansys/actions/code-style@v4 - # with: - # python-version: ${{ env.MAIN_PYTHON_VERSION }} - - # doc-style: - # name: "Documentation style checks" - # runs-on: ubuntu-latest - # steps: - # - name: "Run code style checks" - # uses: pyansys/actions/doc-style@v4 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - - # doc-build: - # name: "Build project documentation" - # runs-on: ubuntu-latest - # needs: doc-style - # steps: - # - name: "Building project documentation" - # uses: pyansys/actions/doc-build@v4 - # with: - # python-version: ${{ env.MAIN_PYTHON_VERSION }} - - # doc-deploy-dev: - # name: "Deploy developers documentation" - # runs-on: ubuntu-latest - # if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') - # needs: doc-build - # steps: - # - name: "Deploy development documentation" - # uses: pyansys/actions/doc-deploy-dev@v4 - # with: - # cname: ${{ env.DOCUMENTATION_CNAME }} - # token: ${{ secrets.GITHUB_TOKEN }} - - # doc-deploy-stable: - # name: "Deploy stable documentation" - # runs-on: ubuntu-latest - # if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - # needs: doc-deploy-dev - # steps: - # - name: "Deploy stable documentation" - # uses: pyansys/actions/doc-deploy-stable@v4 - # with: - # cname: ${{ env.DOCUMENTATION_CNAME }} - # token: ${{ secrets.GITHUB_TOKEN }} + code-style: + name: "Code style checks" + runs-on: ubuntu-latest + steps: + - name: "Run code style checks" + uses: pyansys/actions/code-style@v4 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + doc-style: + name: "Documentation style checks" + runs-on: ubuntu-latest + steps: + - name: "Run code style checks" + uses: pyansys/actions/doc-style@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + doc-build: + name: "Build project documentation" + runs-on: ubuntu-latest + needs: doc-style + steps: + - name: "Building project documentation" + uses: pyansys/actions/doc-build@v4 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + doc-deploy-dev: + name: "Deploy developers documentation" + runs-on: ubuntu-latest + if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') + needs: doc-build + steps: + - name: "Deploy development documentation" + uses: pyansys/actions/doc-deploy-dev@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + + doc-deploy-stable: + name: "Deploy stable documentation" + runs-on: ubuntu-latest + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + needs: doc-deploy-dev + steps: + - name: "Deploy stable documentation" + uses: pyansys/actions/doc-deploy-stable@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} tests: name: "Tests Python ${{ matrix.python }}" runs-on: [self-hosted, pystk] + needs: code-style + if: always() strategy: matrix: python: ["3.8", "3.9", "3.10"] @@ -118,46 +120,12 @@ jobs: docker logs ${{ env.STK_CONTAINER }} docker rm ${{ env.STK_CONTAINER }} - # - name: "Upload coverage results" - # uses: actions/upload-artifact@v3 - # if: matrix.python == env.MAIN_PYTHON_VERSION - # with: - # name: coverage-html - # path: .cov/html - # retention-days: 7 - - # build-library: - # name: "Build library artifacts" - # runs-on: ubuntu-latest - # needs: [doc-deploy-stable, tests] - # steps: - # - name: "Build library source and wheel artifacts" - # uses: pyansys/actions/build-library@v4 - # with: - # library-name: ${{ env.LIBRARY_NAME }} - - # release: - # name: "Release to private and public PyPI and to GitHub" - # if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - # runs-on: ubuntu-latest - # needs: [build-library] - # steps: - - # - name: "Release to the private PyPI repository" - # uses: pyansys/actions/release-pypi-private@v1 - # with: - # library-name: ${{ env.LIBRARY_NAME }} - # twine-username: "__token__" - # twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }} - - # - name: "Release to the public PyPI repository" - # uses: pyansys/actions/release-pypi-public@main - # with: - # library-name: ${{ env.LIBRARY_NAME }} - # twine-username: "__token__" - # twine-token: ${{ secrets.PYPI_TOKEN }} - - # - name: "Release to GitHub" - # uses: pyansys/actions/release-github@main - # with: - # library-name: ${{ env.LIBRARY_NAME }} + build-library: + name: "Build library artifacts" + runs-on: ubuntu-latest + needs: [doc-deploy-stable, tests] + steps: + - name: "Build library source and wheel artifacts" + uses: pyansys/actions/build-library@v4 + with: + library-name: ${{ env.LIBRARY_NAME }} From a46acd9d39f73ace597d031a3d15cd291e4f8ab0 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Fri, 3 Mar 2023 07:53:53 +0100 Subject: [PATCH 06/18] DBG: ci/cd pipelines --- .github/workflows/ci_cd.yml | 57 ++++++++++++++----------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 7f874bf239..2345ba6058 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -21,14 +21,14 @@ concurrency: jobs: - code-style: - name: "Code style checks" - runs-on: ubuntu-latest - steps: - - name: "Run code style checks" - uses: pyansys/actions/code-style@v4 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} + # code-style: + # name: "Code style checks" + # runs-on: ubuntu-latest + # steps: + # - name: "Run code style checks" + # uses: pyansys/actions/code-style@v4 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} doc-style: name: "Documentation style checks" @@ -49,38 +49,14 @@ jobs: with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - doc-deploy-dev: - name: "Deploy developers documentation" - runs-on: ubuntu-latest - if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') - needs: doc-build - steps: - - name: "Deploy development documentation" - uses: pyansys/actions/doc-deploy-dev@v4 - with: - cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.GITHUB_TOKEN }} - - doc-deploy-stable: - name: "Deploy stable documentation" - runs-on: ubuntu-latest - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: doc-deploy-dev - steps: - - name: "Deploy stable documentation" - uses: pyansys/actions/doc-deploy-stable@v4 - with: - cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.GITHUB_TOKEN }} - tests: name: "Tests Python ${{ matrix.python }}" runs-on: [self-hosted, pystk] - needs: code-style + # needs: code-style if: always() strategy: matrix: - python: ["3.8", "3.9", "3.10"] + python: ["3.8", "3.9", "3.10", "3.11"] fail-fast: false steps: @@ -123,9 +99,20 @@ jobs: build-library: name: "Build library artifacts" runs-on: ubuntu-latest - needs: [doc-deploy-stable, tests] + needs: [doc-build, tests] steps: - name: "Build library source and wheel artifacts" uses: pyansys/actions/build-library@v4 with: library-name: ${{ env.LIBRARY_NAME }} + + doc-deploy-dev: + name: "Deploy developers documentation" + runs-on: ubuntu-latest + needs: build-library + if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') + steps: + - uses: pyansys/actions/doc-deploy-dev@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} From 48fe91bcb028eff780f7219d3ebb3130a749ae91 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Fri, 3 Mar 2023 14:50:50 +0100 Subject: [PATCH 07/18] FEAT: add docker files --- docker/linux/stk-engine-py310/Dockerfile | 50 +++++++++++++++++++ .../linux/stk-engine-py310/docker-compose.yml | 10 ++++ docker/linux/stk-engine-py311/Dockerfile | 50 +++++++++++++++++++ .../linux/stk-engine-py311/docker-compose.yml | 10 ++++ docker/linux/stk-engine-py38/Dockerfile | 31 ++++++++++++ .../linux/stk-engine-py38/docker-compose.yml | 10 ++++ docker/linux/stk-engine-py39/Dockerfile | 31 ++++++++++++ .../linux/stk-engine-py39/docker-compose.yml | 10 ++++ docker/linux/stk-engine/docker-compose.yml | 2 +- 9 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 docker/linux/stk-engine-py310/Dockerfile create mode 100644 docker/linux/stk-engine-py310/docker-compose.yml create mode 100644 docker/linux/stk-engine-py311/Dockerfile create mode 100644 docker/linux/stk-engine-py311/docker-compose.yml create mode 100644 docker/linux/stk-engine-py38/Dockerfile create mode 100644 docker/linux/stk-engine-py38/docker-compose.yml create mode 100644 docker/linux/stk-engine-py39/Dockerfile create mode 100644 docker/linux/stk-engine-py39/docker-compose.yml diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile new file mode 100644 index 0000000000..835ff765d4 --- /dev/null +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -0,0 +1,50 @@ +# By default, start from the base STK Engine image +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +# Install system dependencies +USER root +RUN set -e; \ + + # Install basic system utilities + yum -y install make gcc perl-core pcre-devel wget zlib-devel; \ + + # Install required dependencies for Python 3.X + yum -y install libffi-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + # yum -y install python3-tkinter python3.10-tkinter; \ + yum -y install epel-release openssl11 openssl11-libs openssl11-devel; \ + yum clean all; \ + rm -rf /var/cache/yum + +# Install OpenSSL 1.1 +RUN set -e; \ + yum install -y make gcc perl-core pcre-devel wget zlib-devel; \ + wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ + tar -xzvf openssl-1.1.1k.tar.gz; \ + cd openssl-1.1.1k; \ + ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic; \ + make && make install; \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" > /etc/profile.d/openssl.sh; \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc + + +# Install Python 3.10 and generate alias to it +RUN cd /tmp && \ + wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz && \ + tar xzf Python-3.10.10.tgz && \ + cd Python-3.10.10 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + ln -sfn /usr/local/bin/python3.10 /usr/bin/python && \ + ln -sfn /usr/local/bin/pip3.10 /usr/bin/pip + +# Switch back to non-root user +USER stk + +# Update the path to include Python executables +ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \ + PIP_DEFAULT_TIMEOUT=600 \ + PIP_RETRY=50 + +ENTRYPOINT [ "python3.10" ] diff --git a/docker/linux/stk-engine-py310/docker-compose.yml b/docker/linux/stk-engine-py310/docker-compose.yml new file mode 100644 index 0000000000..9dea191cf6 --- /dev/null +++ b/docker/linux/stk-engine-py310/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + stk-python3.10: + image: ansys/stk:latest-centos7-python3.10 + build: + context: . + args: + baseImage: ansys/stk:latest-centos7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py311/Dockerfile b/docker/linux/stk-engine-py311/Dockerfile new file mode 100644 index 0000000000..45f348caf1 --- /dev/null +++ b/docker/linux/stk-engine-py311/Dockerfile @@ -0,0 +1,50 @@ +# By default, start from the base STK Engine image +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +# Install system dependencies +USER root +RUN set -e; \ + + # Install basic system utilities + yum -y install make gcc perl-core pcre-devel wget zlib-devel; \ + + # Install required dependencies for Python 3.X + yum -y install libffi-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + # yum -y install python3-tkinter python3.10-tkinter; \ + yum -y install epel-release openssl11 openssl11-libs openssl11-devel; \ + yum clean all; \ + rm -rf /var/cache/yum + +# Install OpenSSL 1.1 +RUN set -e; \ + yum install -y make gcc perl-core pcre-devel wget zlib-devel; \ + wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ + tar -xzvf openssl-1.1.1k.tar.gz; \ + cd openssl-1.1.1k; \ + ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic; \ + make && make install; \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" > /etc/profile.d/openssl.sh; \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc + + +# Install Python 3.11 and generate alias to it +RUN cd /tmp && \ + wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz && \ + tar xzf Python-3.11.2.tgz && \ + cd Python-3.11.2 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + ln -sfn /usr/local/bin/python3.11 /usr/bin/python && \ + ln -sfn /usr/local/bin/pip3.11 /usr/bin/pip + +# Switch back to non-root user +USER stk + +# Update the path to include Python executables +ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \ + PIP_DEFAULT_TIMEOUT=600 \ + PIP_RETRY=50 + +ENTRYPOINT [ "python3.11" ] diff --git a/docker/linux/stk-engine-py311/docker-compose.yml b/docker/linux/stk-engine-py311/docker-compose.yml new file mode 100644 index 0000000000..ec93258850 --- /dev/null +++ b/docker/linux/stk-engine-py311/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + stk-python3.11: + image: ansys/stk:latest-centos7-python3.11 + build: + context: . + args: + baseImage: ansys/stk:latest-centos7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile new file mode 100644 index 0000000000..7afa88c645 --- /dev/null +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -0,0 +1,31 @@ +# By default, start from the base STK Engine image +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +# Install Python +USER root +RUN set -e; \ + yum -y install wget make gcc openssl-devel bzip2-devel libffi-devel tk-devel; \ + yum -y install python3 python3-tkinter python3.8-tkinter; \ + yum clean all; \ + rm -rf /var/cache/yum + +# Install Python 3.8 and generate alias to it +RUN cd /tmp && \ + wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz && \ + tar xzf Python-3.8.16.tgz && \ + cd Python-3.8.16 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + ln -sfn /usr/local/bin/python3.8 /usr/bin/python && \ + ln -sfn /usr/local/bin/pip3.8 /usr/bin/pip + +# Switch back to non-root user +USER stk + +# Update the path to include Python executables +ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \ + PIP_DEFAULT_TIMEOUT=600 \ + PIP_RETRY=50 + +ENTRYPOINT [ "python3.8" ] diff --git a/docker/linux/stk-engine-py38/docker-compose.yml b/docker/linux/stk-engine-py38/docker-compose.yml new file mode 100644 index 0000000000..f3d7f9bed3 --- /dev/null +++ b/docker/linux/stk-engine-py38/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + stk-python3.8: + image: ansys/stk:latest-centos7-python3.8 + build: + context: . + args: + baseImage: ansys/stk:latest-centos7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py39/Dockerfile b/docker/linux/stk-engine-py39/Dockerfile new file mode 100644 index 0000000000..a297cd364f --- /dev/null +++ b/docker/linux/stk-engine-py39/Dockerfile @@ -0,0 +1,31 @@ +# By default, start from the base STK Engine image +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +# Install Python +USER root +RUN set -e; \ + yum -y install wget make gcc openssl-devel bzip2-devel libffi-devel tk-devel; \ + yum -y install python3 python3-tkinter python3.9-tkinter; \ + yum clean all; \ + rm -rf /var/cache/yum + +# Install Python 3.9 and generate alias to it +RUN cd /tmp && \ + wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz && \ + tar xzf Python-3.9.16.tgz && \ + cd Python-3.9.16 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + ln -sfn /usr/local/bin/python3.9 /usr/bin/python && \ + ln -sfn /usr/local/bin/pip3.9 /usr/bin/pip + +# Switch back to non-root user +USER stk + +# Update the path to include Python executables +ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \ + PIP_DEFAULT_TIMEOUT=600 \ + PIP_RETRY=50 + +ENTRYPOINT [ "python3.9" ] diff --git a/docker/linux/stk-engine-py39/docker-compose.yml b/docker/linux/stk-engine-py39/docker-compose.yml new file mode 100644 index 0000000000..1779a6d0d0 --- /dev/null +++ b/docker/linux/stk-engine-py39/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + stk-python3.9: + image: ansys/stk:latest-centos7-python3.9 + build: + context: . + args: + baseImage: ansys/stk:latest-centos7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine/docker-compose.yml b/docker/linux/stk-engine/docker-compose.yml index 9fb23743ab..01c2606f51 100644 --- a/docker/linux/stk-engine/docker-compose.yml +++ b/docker/linux/stk-engine/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.8' services: stk: image: ansys/stk:latest-centos7 From 63c0ddbe29ea9bbe5b4da5c299e54aa90a2fc793 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Fri, 3 Mar 2023 14:52:30 +0100 Subject: [PATCH 08/18] CI: rename container --- .github/workflows/ci_cd.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 2345ba6058..d19a12750c 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -66,7 +66,7 @@ jobs: - name: "Generate the name of the docker image and the container" run: | python_image_name=${{ env.STK_DOCKER_IMAGE }}-python${{ matrix.python }} - container_name=stk-py${{ matrix.python }} + container_name=stk-python${{ matrix.python }} echo "STK_PYTHON_IMAGE=$python_image_name" >> $GITHUB_ENV echo "STK_CONTAINER=$container_name" >> $GITHUB_ENV @@ -101,13 +101,12 @@ jobs: runs-on: ubuntu-latest needs: [doc-build, tests] steps: - - name: "Build library source and wheel artifacts" - uses: pyansys/actions/build-library@v4 + - uses: pyansys/actions/build-library@v4 with: library-name: ${{ env.LIBRARY_NAME }} doc-deploy-dev: - name: "Deploy developers documentation" + name: "Deploy development documentation" runs-on: ubuntu-latest needs: build-library if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') From 90830f456b2e75fa8885c144c2392d5a62791ee3 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Fri, 3 Mar 2023 15:32:43 +0100 Subject: [PATCH 09/18] MAINT: clean Dockerimage files --- docker/linux/stk-engine-py38/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile index 7afa88c645..3377bc4651 100644 --- a/docker/linux/stk-engine-py38/Dockerfile +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -6,7 +6,6 @@ FROM ${baseImage} USER root RUN set -e; \ yum -y install wget make gcc openssl-devel bzip2-devel libffi-devel tk-devel; \ - yum -y install python3 python3-tkinter python3.8-tkinter; \ yum clean all; \ rm -rf /var/cache/yum From d556ee5e2fd3255b2ac4021703e25212448b601d Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Mon, 6 Mar 2023 16:23:23 +0100 Subject: [PATCH 10/18] MAINT: clean docker files --- docker/linux/stk-engine-py310/Dockerfile | 23 ++++++++++++++--------- docker/linux/stk-engine-py311/Dockerfile | 23 ++++++++++++++--------- docker/linux/stk-engine-py38/Dockerfile | 15 +++++++++++++-- docker/linux/stk-engine-py39/Dockerfile | 16 +++++++++++++--- 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile index 835ff765d4..ab9988d7ed 100644 --- a/docker/linux/stk-engine-py310/Dockerfile +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -6,20 +6,24 @@ FROM ${baseImage} USER root RUN set -e; \ - # Install basic system utilities - yum -y install make gcc perl-core pcre-devel wget zlib-devel; \ + # Install basic development utilities + yum groupinstall -y development; \ + yum -y install gcc make tar wget; \ + + # Install OpenSSL 1.1 (required for Python >= 3.10) dependencies + yum -y perl-core pcre-devel; \ # Install required dependencies for Python 3.X - yum -y install libffi-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel; \ - yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ - # yum -y install python3-tkinter python3.10-tkinter; \ - yum -y install epel-release openssl11 openssl11-libs openssl11-devel; \ + yum -y install bzip2-devel libffi-devel tk-devel; \ + yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + + # Clean all unnecessary files yum clean all; \ rm -rf /var/cache/yum -# Install OpenSSL 1.1 +# Install OpenSSL 1.1 (required by Python >= 3.10) RUN set -e; \ - yum install -y make gcc perl-core pcre-devel wget zlib-devel; \ wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ tar -xzvf openssl-1.1.1k.tar.gz; \ cd openssl-1.1.1k; \ @@ -29,7 +33,8 @@ RUN set -e; \ echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc -# Install Python 3.10 and generate alias to it +# Install Python 3.10 and create a symbolic link named "python". +# This overrides the default Python 2.7 in CentOS7. RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz && \ tar xzf Python-3.10.10.tgz && \ diff --git a/docker/linux/stk-engine-py311/Dockerfile b/docker/linux/stk-engine-py311/Dockerfile index 45f348caf1..7aff0f9030 100644 --- a/docker/linux/stk-engine-py311/Dockerfile +++ b/docker/linux/stk-engine-py311/Dockerfile @@ -6,20 +6,24 @@ FROM ${baseImage} USER root RUN set -e; \ - # Install basic system utilities - yum -y install make gcc perl-core pcre-devel wget zlib-devel; \ + # Install basic development utilities + yum groupinstall -y development; \ + yum -y install gcc make tar wget; \ + + # Install OpenSSL 1.1 (required for Python >= 3.10) dependencies + yum -y perl-core pcre-devel; \ # Install required dependencies for Python 3.X - yum -y install libffi-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel; \ - yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ - # yum -y install python3-tkinter python3.10-tkinter; \ - yum -y install epel-release openssl11 openssl11-libs openssl11-devel; \ + yum -y install bzip2-devel libffi-devel tk-devel; \ + yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + + # Clean all unnecessary files yum clean all; \ rm -rf /var/cache/yum -# Install OpenSSL 1.1 +# Install OpenSSL 1.1 (required by Python >= 3.10) RUN set -e; \ - yum install -y make gcc perl-core pcre-devel wget zlib-devel; \ wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ tar -xzvf openssl-1.1.1k.tar.gz; \ cd openssl-1.1.1k; \ @@ -29,7 +33,8 @@ RUN set -e; \ echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc -# Install Python 3.11 and generate alias to it +# Install Python 3.11 and create a symbolic link named "python". +# This overrides the default Python 2.7 in CentOS7. RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz && \ tar xzf Python-3.11.2.tgz && \ diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile index 3377bc4651..a29c4aaf3f 100644 --- a/docker/linux/stk-engine-py38/Dockerfile +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -5,11 +5,22 @@ FROM ${baseImage} # Install Python USER root RUN set -e; \ - yum -y install wget make gcc openssl-devel bzip2-devel libffi-devel tk-devel; \ + + # Install basic development utilities + yum groupinstall -y development; \ + yum -y install gcc make tar wget; \ + + # Install required dependencies for Python 3.X + yum -y install openssl-devel bzip2-devel libffi-devel tk-devel; \ + yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + + # Clean all unnecessary files yum clean all; \ rm -rf /var/cache/yum -# Install Python 3.8 and generate alias to it +# Install Python 3.8 and create a symbolic link named "python". +# This overrides the default Python 2.7 in CentOS7. RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz && \ tar xzf Python-3.8.16.tgz && \ diff --git a/docker/linux/stk-engine-py39/Dockerfile b/docker/linux/stk-engine-py39/Dockerfile index a297cd364f..5ad9a622b3 100644 --- a/docker/linux/stk-engine-py39/Dockerfile +++ b/docker/linux/stk-engine-py39/Dockerfile @@ -5,12 +5,22 @@ FROM ${baseImage} # Install Python USER root RUN set -e; \ - yum -y install wget make gcc openssl-devel bzip2-devel libffi-devel tk-devel; \ - yum -y install python3 python3-tkinter python3.9-tkinter; \ + + # Install basic development utilities + yum groupinstall -y development; \ + yum -y install gcc make tar wget; \ + + # Install required dependencies for Python 3.X + yum -y install openssl-devel bzip2-devel libffi-devel tk-devel; \ + yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + + # Clean all unnecessary files yum clean all; \ rm -rf /var/cache/yum -# Install Python 3.9 and generate alias to it +# Install Python 3.9 and create a symbolic link named "python". +# This overrides the default Python 2.7 in CentOS7. RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz && \ tar xzf Python-3.9.16.tgz && \ From d133358de76c7b9ad62d3e566d36b02744f0b663 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Mon, 6 Mar 2023 17:11:22 +0100 Subject: [PATCH 11/18] FIX: installation command --- docker/linux/stk-engine-py310/Dockerfile | 2 +- docker/linux/stk-engine-py311/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile index ab9988d7ed..33ddfa0b15 100644 --- a/docker/linux/stk-engine-py310/Dockerfile +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -11,7 +11,7 @@ RUN set -e; \ yum -y install gcc make tar wget; \ # Install OpenSSL 1.1 (required for Python >= 3.10) dependencies - yum -y perl-core pcre-devel; \ + yum -y install perl-core pcre-devel; \ # Install required dependencies for Python 3.X yum -y install bzip2-devel libffi-devel tk-devel; \ diff --git a/docker/linux/stk-engine-py311/Dockerfile b/docker/linux/stk-engine-py311/Dockerfile index 7aff0f9030..f239c80bdc 100644 --- a/docker/linux/stk-engine-py311/Dockerfile +++ b/docker/linux/stk-engine-py311/Dockerfile @@ -11,7 +11,7 @@ RUN set -e; \ yum -y install gcc make tar wget; \ # Install OpenSSL 1.1 (required for Python >= 3.10) dependencies - yum -y perl-core pcre-devel; \ + yum -y install perl-core pcre-devel; \ # Install required dependencies for Python 3.X yum -y install bzip2-devel libffi-devel tk-devel; \ From cfe05e9fafc424be9f0718354d509f21e6ae23c0 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 7 Mar 2023 07:36:10 +0100 Subject: [PATCH 12/18] FIX: remove duplicated dependencies --- docker/linux/stk-engine-py310/Dockerfile | 2 +- docker/linux/stk-engine-py311/Dockerfile | 2 +- docker/linux/stk-engine-py38/Dockerfile | 2 +- docker/linux/stk-engine-py39/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile index 33ddfa0b15..30cbcd54d9 100644 --- a/docker/linux/stk-engine-py310/Dockerfile +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -15,7 +15,7 @@ RUN set -e; \ # Install required dependencies for Python 3.X yum -y install bzip2-devel libffi-devel tk-devel; \ - yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install zlib-devel ncurses-devel sqlite-devel; \ yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ # Clean all unnecessary files diff --git a/docker/linux/stk-engine-py311/Dockerfile b/docker/linux/stk-engine-py311/Dockerfile index f239c80bdc..cdee09176f 100644 --- a/docker/linux/stk-engine-py311/Dockerfile +++ b/docker/linux/stk-engine-py311/Dockerfile @@ -15,7 +15,7 @@ RUN set -e; \ # Install required dependencies for Python 3.X yum -y install bzip2-devel libffi-devel tk-devel; \ - yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install zlib-devel ncurses-devel sqlite-devel; \ yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ # Clean all unnecessary files diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile index a29c4aaf3f..8bb305ebae 100644 --- a/docker/linux/stk-engine-py38/Dockerfile +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -12,7 +12,7 @@ RUN set -e; \ # Install required dependencies for Python 3.X yum -y install openssl-devel bzip2-devel libffi-devel tk-devel; \ - yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install zlib-devel ncurses-devel sqlite-devel; \ yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ # Clean all unnecessary files diff --git a/docker/linux/stk-engine-py39/Dockerfile b/docker/linux/stk-engine-py39/Dockerfile index 5ad9a622b3..682de5c667 100644 --- a/docker/linux/stk-engine-py39/Dockerfile +++ b/docker/linux/stk-engine-py39/Dockerfile @@ -12,7 +12,7 @@ RUN set -e; \ # Install required dependencies for Python 3.X yum -y install openssl-devel bzip2-devel libffi-devel tk-devel; \ - yum -y install libffi-devel zlib-devel ncurses-devel sqlite-devel; \ + yum -y install zlib-devel ncurses-devel sqlite-devel; \ yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ # Clean all unnecessary files From 9b065d0cfcc0ea7b7f7a497c960c8b3b9373c44c Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 7 Mar 2023 08:38:27 +0100 Subject: [PATCH 13/18] MAINT: restore CI jobs --- .github/workflows/ci_cd.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d19a12750c..d6af2f47ec 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -21,17 +21,17 @@ concurrency: jobs: - # code-style: - # name: "Code style checks" - # runs-on: ubuntu-latest - # steps: - # - name: "Run code style checks" - # uses: pyansys/actions/code-style@v4 - # with: - # python-version: ${{ env.MAIN_PYTHON_VERSION }} + code-style: + name: "Code style checks" + runs-on: ubuntu-latest + steps: + - name: "Run code style checks" + uses: pyansys/actions/code-style@v4 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} doc-style: - name: "Documentation style checks" + name: "Doc style checks" runs-on: ubuntu-latest steps: - name: "Run code style checks" @@ -40,7 +40,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} doc-build: - name: "Build project documentation" + name: "Doc build" runs-on: ubuntu-latest needs: doc-style steps: @@ -53,7 +53,6 @@ jobs: name: "Tests Python ${{ matrix.python }}" runs-on: [self-hosted, pystk] # needs: code-style - if: always() strategy: matrix: python: ["3.8", "3.9", "3.10", "3.11"] @@ -97,7 +96,7 @@ jobs: docker rm ${{ env.STK_CONTAINER }} build-library: - name: "Build library artifacts" + name: "Build library" runs-on: ubuntu-latest needs: [doc-build, tests] steps: @@ -106,7 +105,7 @@ jobs: library-name: ${{ env.LIBRARY_NAME }} doc-deploy-dev: - name: "Deploy development documentation" + name: "Deploy dev docs" runs-on: ubuntu-latest needs: build-library if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main') From 87d420fcfccc949cd165e77eccf21363e18bcdec Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 7 Mar 2023 11:33:11 +0100 Subject: [PATCH 14/18] FEAT: add container_name in docker-compose.yml files --- docker/linux/stk-engine-py310/docker-compose.yml | 1 + docker/linux/stk-engine-py311/docker-compose.yml | 1 + docker/linux/stk-engine-py38/docker-compose.yml | 1 + docker/linux/stk-engine-py39/docker-compose.yml | 1 + docker/linux/stk-engine/docker-compose.yml | 1 + 5 files changed, 5 insertions(+) diff --git a/docker/linux/stk-engine-py310/docker-compose.yml b/docker/linux/stk-engine-py310/docker-compose.yml index 9dea191cf6..b0da15eba3 100644 --- a/docker/linux/stk-engine-py310/docker-compose.yml +++ b/docker/linux/stk-engine-py310/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: stk-python3.10: image: ansys/stk:latest-centos7-python3.10 + container_name: stk-python3.10 build: context: . args: diff --git a/docker/linux/stk-engine-py311/docker-compose.yml b/docker/linux/stk-engine-py311/docker-compose.yml index ec93258850..da29436913 100644 --- a/docker/linux/stk-engine-py311/docker-compose.yml +++ b/docker/linux/stk-engine-py311/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: stk-python3.11: image: ansys/stk:latest-centos7-python3.11 + container_name: stk-python3.11 build: context: . args: diff --git a/docker/linux/stk-engine-py38/docker-compose.yml b/docker/linux/stk-engine-py38/docker-compose.yml index f3d7f9bed3..7969fca366 100644 --- a/docker/linux/stk-engine-py38/docker-compose.yml +++ b/docker/linux/stk-engine-py38/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: stk-python3.8: image: ansys/stk:latest-centos7-python3.8 + container_name: stk-python3.8 build: context: . args: diff --git a/docker/linux/stk-engine-py39/docker-compose.yml b/docker/linux/stk-engine-py39/docker-compose.yml index 1779a6d0d0..76e0be9b26 100644 --- a/docker/linux/stk-engine-py39/docker-compose.yml +++ b/docker/linux/stk-engine-py39/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: stk-python3.9: image: ansys/stk:latest-centos7-python3.9 + container_name: stk-python3.9 build: context: . args: diff --git a/docker/linux/stk-engine/docker-compose.yml b/docker/linux/stk-engine/docker-compose.yml index 01c2606f51..e327e6500e 100644 --- a/docker/linux/stk-engine/docker-compose.yml +++ b/docker/linux/stk-engine/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: stk: image: ansys/stk:latest-centos7 + container_name: stk build: context: . args: From e549a25101a9f6f4871b74aa50fd0df0732c5194 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 7 Mar 2023 16:54:51 +0100 Subject: [PATCH 15/18] FEAT: use multi-stage strategy for Python images --- docker/linux/stk-engine-py310/Dockerfile | 34 ++---------------- .../linux/stk-engine-py310/docker-compose.yml | 2 +- docker/linux/stk-engine-py311/Dockerfile | 34 ++---------------- .../linux/stk-engine-py311/docker-compose.yml | 2 +- docker/linux/stk-engine-py38/Dockerfile | 18 +--------- .../linux/stk-engine-py38/docker-compose.yml | 2 +- docker/linux/stk-engine-py39/Dockerfile | 18 +--------- .../linux/stk-engine-py39/docker-compose.yml | 2 +- docker/linux/stk-engine-pybase/Dockerfile | 36 +++++++++++++++++++ .../stk-engine-pybase/docker-compose.yml | 11 ++++++ docker/linux/stk-engine/Dockerfile | 2 +- 11 files changed, 58 insertions(+), 103 deletions(-) create mode 100644 docker/linux/stk-engine-pybase/Dockerfile create mode 100644 docker/linux/stk-engine-pybase/docker-compose.yml diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile index 30cbcd54d9..1ae29bd424 100644 --- a/docker/linux/stk-engine-py310/Dockerfile +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -1,40 +1,10 @@ # By default, start from the base STK Engine image -ARG baseImage=ansys/stk:latest-centos7 +ARG baseImage=ansys/stk:latest-centos7-pybase FROM ${baseImage} -# Install system dependencies -USER root -RUN set -e; \ - - # Install basic development utilities - yum groupinstall -y development; \ - yum -y install gcc make tar wget; \ - - # Install OpenSSL 1.1 (required for Python >= 3.10) dependencies - yum -y install perl-core pcre-devel; \ - - # Install required dependencies for Python 3.X - yum -y install bzip2-devel libffi-devel tk-devel; \ - yum -y install zlib-devel ncurses-devel sqlite-devel; \ - yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ - - # Clean all unnecessary files - yum clean all; \ - rm -rf /var/cache/yum - -# Install OpenSSL 1.1 (required by Python >= 3.10) -RUN set -e; \ - wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ - tar -xzvf openssl-1.1.1k.tar.gz; \ - cd openssl-1.1.1k; \ - ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic; \ - make && make install; \ - echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" > /etc/profile.d/openssl.sh; \ - echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc - - # Install Python 3.10 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. +USER root RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz && \ tar xzf Python-3.10.10.tgz && \ diff --git a/docker/linux/stk-engine-py310/docker-compose.yml b/docker/linux/stk-engine-py310/docker-compose.yml index b0da15eba3..6d27a6dbe1 100644 --- a/docker/linux/stk-engine-py310/docker-compose.yml +++ b/docker/linux/stk-engine-py310/docker-compose.yml @@ -6,6 +6,6 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7 + baseImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py311/Dockerfile b/docker/linux/stk-engine-py311/Dockerfile index cdee09176f..8bef512205 100644 --- a/docker/linux/stk-engine-py311/Dockerfile +++ b/docker/linux/stk-engine-py311/Dockerfile @@ -1,40 +1,10 @@ # By default, start from the base STK Engine image -ARG baseImage=ansys/stk:latest-centos7 +ARG baseImage=ansys/stk:latest-centos7-pybase FROM ${baseImage} -# Install system dependencies -USER root -RUN set -e; \ - - # Install basic development utilities - yum groupinstall -y development; \ - yum -y install gcc make tar wget; \ - - # Install OpenSSL 1.1 (required for Python >= 3.10) dependencies - yum -y install perl-core pcre-devel; \ - - # Install required dependencies for Python 3.X - yum -y install bzip2-devel libffi-devel tk-devel; \ - yum -y install zlib-devel ncurses-devel sqlite-devel; \ - yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ - - # Clean all unnecessary files - yum clean all; \ - rm -rf /var/cache/yum - -# Install OpenSSL 1.1 (required by Python >= 3.10) -RUN set -e; \ - wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ - tar -xzvf openssl-1.1.1k.tar.gz; \ - cd openssl-1.1.1k; \ - ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic; \ - make && make install; \ - echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" > /etc/profile.d/openssl.sh; \ - echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc - - # Install Python 3.11 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. +USER root RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz && \ tar xzf Python-3.11.2.tgz && \ diff --git a/docker/linux/stk-engine-py311/docker-compose.yml b/docker/linux/stk-engine-py311/docker-compose.yml index da29436913..f8ad597a86 100644 --- a/docker/linux/stk-engine-py311/docker-compose.yml +++ b/docker/linux/stk-engine-py311/docker-compose.yml @@ -6,6 +6,6 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7 + baseImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile index 8bb305ebae..42dd72ea97 100644 --- a/docker/linux/stk-engine-py38/Dockerfile +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -2,25 +2,9 @@ ARG baseImage=ansys/stk:latest-centos7 FROM ${baseImage} -# Install Python -USER root -RUN set -e; \ - - # Install basic development utilities - yum groupinstall -y development; \ - yum -y install gcc make tar wget; \ - - # Install required dependencies for Python 3.X - yum -y install openssl-devel bzip2-devel libffi-devel tk-devel; \ - yum -y install zlib-devel ncurses-devel sqlite-devel; \ - yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ - - # Clean all unnecessary files - yum clean all; \ - rm -rf /var/cache/yum - # Install Python 3.8 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. +USER root RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz && \ tar xzf Python-3.8.16.tgz && \ diff --git a/docker/linux/stk-engine-py38/docker-compose.yml b/docker/linux/stk-engine-py38/docker-compose.yml index 7969fca366..c5a5da8699 100644 --- a/docker/linux/stk-engine-py38/docker-compose.yml +++ b/docker/linux/stk-engine-py38/docker-compose.yml @@ -6,6 +6,6 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7 + baseImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py39/Dockerfile b/docker/linux/stk-engine-py39/Dockerfile index 682de5c667..ee9d581c0a 100644 --- a/docker/linux/stk-engine-py39/Dockerfile +++ b/docker/linux/stk-engine-py39/Dockerfile @@ -2,25 +2,9 @@ ARG baseImage=ansys/stk:latest-centos7 FROM ${baseImage} -# Install Python -USER root -RUN set -e; \ - - # Install basic development utilities - yum groupinstall -y development; \ - yum -y install gcc make tar wget; \ - - # Install required dependencies for Python 3.X - yum -y install openssl-devel bzip2-devel libffi-devel tk-devel; \ - yum -y install zlib-devel ncurses-devel sqlite-devel; \ - yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ - - # Clean all unnecessary files - yum clean all; \ - rm -rf /var/cache/yum - # Install Python 3.9 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. +USER root RUN cd /tmp && \ wget https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz && \ tar xzf Python-3.9.16.tgz && \ diff --git a/docker/linux/stk-engine-py39/docker-compose.yml b/docker/linux/stk-engine-py39/docker-compose.yml index 76e0be9b26..b2f2269dc0 100644 --- a/docker/linux/stk-engine-py39/docker-compose.yml +++ b/docker/linux/stk-engine-py39/docker-compose.yml @@ -6,6 +6,6 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7 + baseImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-pybase/Dockerfile b/docker/linux/stk-engine-pybase/Dockerfile new file mode 100644 index 0000000000..4579426710 --- /dev/null +++ b/docker/linux/stk-engine-pybase/Dockerfile @@ -0,0 +1,36 @@ +# By default, start from the base STK Engine image +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +# Install system dependencies +USER root +RUN set -e; \ + + # Install basic development utilities + yum groupinstall -y development; \ + yum -y install gcc make tar wget; \ + + # Install OpenSSL 1.1 dependencies + yum -y install perl-core pcre-devel; \ + + # Install required dependencies for Python 3.X + yum -y install bzip2-devel libffi-devel tk-devel; \ + yum -y install zlib-devel ncurses-devel sqlite-devel; \ + yum -y install readline-devel gdbm-devel db4-devel libpcap-devel xz-devel; \ + + # Clean all unnecessary files + yum clean all; \ + rm -rf /var/cache/yum + +# Install OpenSSL 1.1 +RUN set -e; \ + wget --no-check-certificate https://ftp.openssl.org/source/openssl-1.1.1k.tar.gz; \ + tar -xzvf openssl-1.1.1k.tar.gz; \ + cd openssl-1.1.1k; \ + ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic; \ + make && make install; \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" > /etc/profile.d/openssl.sh; \ + echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}" >> .bashrc + + +CMD echo 'Extend this container by installing Python.' diff --git a/docker/linux/stk-engine-pybase/docker-compose.yml b/docker/linux/stk-engine-pybase/docker-compose.yml new file mode 100644 index 0000000000..eb6396bfc5 --- /dev/null +++ b/docker/linux/stk-engine-pybase/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.8' +services: + stk-python-common: + image: ansys/stk:latest-centos7-python-common + container_name: stk-python-common + build: + context: . + args: + baseImage: ansys/stk:latest-centos7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine/Dockerfile b/docker/linux/stk-engine/Dockerfile index 90c527221c..b94b1bdf38 100644 --- a/docker/linux/stk-engine/Dockerfile +++ b/docker/linux/stk-engine/Dockerfile @@ -47,4 +47,4 @@ ENV LD_LIBRARY_PATH="${STK_USER_HOME}/bin" \ # Run new user install RUN stkxnewuser /force /allowOnline=yes -CMD echo 'STK Engine requires a host application to run. Shutting down this container.' +CMD echo 'STK Engine requires a host application to run. Shutting down this container.' From d5ebeb22ca26f934ad8ab49d96d5f689ba28c401 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 9 Mar 2023 09:52:24 +0100 Subject: [PATCH 16/18] FEAT: optimize docker images --- .github/workflows/ci_cd.yml | 2 +- docker/linux/docker-compose.yml | 60 +++++++++++++++++++ docker/linux/stk-engine-py310/Dockerfile | 24 ++++++-- docker/linux/stk-engine-py311/Dockerfile | 25 -------- .../linux/stk-engine-py311/docker-compose.yml | 11 ---- docker/linux/stk-engine-py38/Dockerfile | 26 ++++++-- docker/linux/stk-engine-py39/Dockerfile | 26 ++++++-- 7 files changed, 123 insertions(+), 51 deletions(-) create mode 100644 docker/linux/docker-compose.yml delete mode 100644 docker/linux/stk-engine-py311/Dockerfile delete mode 100644 docker/linux/stk-engine-py311/docker-compose.yml diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d6af2f47ec..8db8d6be22 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -55,7 +55,7 @@ jobs: # needs: code-style strategy: matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.8", "3.9", "3.10"] fail-fast: false steps: diff --git a/docker/linux/docker-compose.yml b/docker/linux/docker-compose.yml new file mode 100644 index 0000000000..da471514fc --- /dev/null +++ b/docker/linux/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3.8' +services: + + stk: + image: ansys/stk:latest-centos7 + container_name: stk + build: + context: ./stk-engine + args: + baseImage: centos:7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE + + stk-pybase: + image: ansys/stk:latest-centos7-pybase + depends_on: + - stk + container_name: stk-pybase + build: + context: ./stk-engine-pybase + args: + baseImage: ansys/stk:latest-centos7 + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE + + stk-python3.8: + image: ansys/stk:latest-centos7-python3.8 + depends_on: + - stk-pybase + container_name: stk-python3.8 + build: + context: ./stk-engine-py38 + args: + baseImage: ansys/stk:latest-centos7-pybase + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE + + stk-python3.9: + image: ansys/stk:latest-centos7-python3.9 + depends_on: + - stk-pybase + container_name: stk-python3.9 + build: + context: ./stk-engine-py39 + args: + baseImage: ansys/stk:latest-centos7-pybase + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE + + stk-python3.10: + image: ansys/stk:latest-centos7-python3.10 + depends_on: + - stk-pybase + container_name: stk-python3.10 + build: + context: ./stk-engine-py310 + args: + baseImage: ansys/stk:latest-centos7-pybase + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile index 1ae29bd424..3518bd0379 100644 --- a/docker/linux/stk-engine-py310/Dockerfile +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -1,6 +1,10 @@ -# By default, start from the base STK Engine image +# By default, start from the base STK Engine Python image ARG baseImage=ansys/stk:latest-centos7-pybase -FROM ${baseImage} +FROM ${baseImage} as builder + +############################################## +# 1) Build Python into its own builder stage +############################################## # Install Python 3.10 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. @@ -10,8 +14,20 @@ RUN cd /tmp && \ tar xzf Python-3.10.10.tgz && \ cd Python-3.10.10 && \ ./configure --enable-optimizations && \ - make altinstall && \ - ln -sfn /usr/local/bin/python3.10 /usr/bin/python && \ + make altinstall + +############################################################# +# 2) Copy the Python build to the system in the second stage +############################################################# + +# Switch back to non-root user +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +COPY --from=builder /usr/local/bin/python3.10 /usr/local/bin/python3.10 +COPY --from=builder /usr/local/bin/pip3.10 /usr/local/bin/pip3.10 + +RUN ln -sfn /usr/local/bin/python3.10 /usr/bin/python && \ ln -sfn /usr/local/bin/pip3.10 /usr/bin/pip # Switch back to non-root user diff --git a/docker/linux/stk-engine-py311/Dockerfile b/docker/linux/stk-engine-py311/Dockerfile deleted file mode 100644 index 8bef512205..0000000000 --- a/docker/linux/stk-engine-py311/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -# By default, start from the base STK Engine image -ARG baseImage=ansys/stk:latest-centos7-pybase -FROM ${baseImage} - -# Install Python 3.11 and create a symbolic link named "python". -# This overrides the default Python 2.7 in CentOS7. -USER root -RUN cd /tmp && \ - wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz && \ - tar xzf Python-3.11.2.tgz && \ - cd Python-3.11.2 && \ - ./configure --enable-optimizations && \ - make altinstall && \ - ln -sfn /usr/local/bin/python3.11 /usr/bin/python && \ - ln -sfn /usr/local/bin/pip3.11 /usr/bin/pip - -# Switch back to non-root user -USER stk - -# Update the path to include Python executables -ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \ - PIP_DEFAULT_TIMEOUT=600 \ - PIP_RETRY=50 - -ENTRYPOINT [ "python3.11" ] diff --git a/docker/linux/stk-engine-py311/docker-compose.yml b/docker/linux/stk-engine-py311/docker-compose.yml deleted file mode 100644 index f8ad597a86..0000000000 --- a/docker/linux/stk-engine-py311/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3.8' -services: - stk-python3.11: - image: ansys/stk:latest-centos7-python3.11 - container_name: stk-python3.11 - build: - context: . - args: - baseImage: ansys/stk:latest-centos7-pybase - environment: - - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile index 42dd72ea97..bbdb47f033 100644 --- a/docker/linux/stk-engine-py38/Dockerfile +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -1,6 +1,10 @@ -# By default, start from the base STK Engine image -ARG baseImage=ansys/stk:latest-centos7 -FROM ${baseImage} +# By default, start from the base STK Engine Python image +ARG baseImage=ansys/stk:latest-centos7-pybase +FROM ${baseImage} as builder + +############################################## +# 1) Build Python into its own builder stage +############################################## # Install Python 3.8 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. @@ -10,8 +14,20 @@ RUN cd /tmp && \ tar xzf Python-3.8.16.tgz && \ cd Python-3.8.16 && \ ./configure --enable-optimizations && \ - make altinstall && \ - ln -sfn /usr/local/bin/python3.8 /usr/bin/python && \ + make altinstall + +############################################################# +# 2) Copy the Python build to the system in the second stage +############################################################# + +# Switch back to non-root user +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +COPY --from=builder /usr/local/bin/python3.8 /usr/local/bin/python3.8 +COPY --from=builder /usr/local/bin/pip3.8 /usr/local/bin/pip3.8 + +RUN ln -sfn /usr/local/bin/python3.8 /usr/bin/python && \ ln -sfn /usr/local/bin/pip3.8 /usr/bin/pip # Switch back to non-root user diff --git a/docker/linux/stk-engine-py39/Dockerfile b/docker/linux/stk-engine-py39/Dockerfile index ee9d581c0a..f47dce5fef 100644 --- a/docker/linux/stk-engine-py39/Dockerfile +++ b/docker/linux/stk-engine-py39/Dockerfile @@ -1,6 +1,10 @@ -# By default, start from the base STK Engine image -ARG baseImage=ansys/stk:latest-centos7 -FROM ${baseImage} +# By default, start from the base STK Engine Python image +ARG baseImage=ansys/stk:latest-centos7-pybase +FROM ${baseImage} as builder + +############################################## +# 1) Build Python into its own builder stage +############################################## # Install Python 3.9 and create a symbolic link named "python". # This overrides the default Python 2.7 in CentOS7. @@ -10,8 +14,20 @@ RUN cd /tmp && \ tar xzf Python-3.9.16.tgz && \ cd Python-3.9.16 && \ ./configure --enable-optimizations && \ - make altinstall && \ - ln -sfn /usr/local/bin/python3.9 /usr/bin/python && \ + make altinstall + +############################################################# +# 2) Copy the Python build to the system in the second stage +############################################################# + +# Switch back to non-root user +ARG baseImage=ansys/stk:latest-centos7 +FROM ${baseImage} + +COPY --from=builder /usr/local/bin/python3.9 /usr/local/bin/python3.9 +COPY --from=builder /usr/local/bin/pip3.9 /usr/local/bin/pip3.9 + +RUN ln -sfn /usr/local/bin/python3.9 /usr/bin/python && \ ln -sfn /usr/local/bin/pip3.9 /usr/bin/pip # Switch back to non-root user From 16703de6df484f721ba54e49bdf23500ad15f3c5 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 16 Mar 2023 07:44:35 +0100 Subject: [PATCH 17/18] FIX: copy Python STD lib into the final image --- docker/linux/docker-compose.yml | 9 ++++++--- docker/linux/stk-engine-py310/Dockerfile | 9 ++++++--- docker/linux/stk-engine-py310/docker-compose.yml | 3 ++- docker/linux/stk-engine-py38/Dockerfile | 9 ++++++--- docker/linux/stk-engine-py38/docker-compose.yml | 5 ++++- docker/linux/stk-engine-py39/Dockerfile | 9 ++++++--- docker/linux/stk-engine-py39/docker-compose.yml | 3 ++- 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/docker/linux/docker-compose.yml b/docker/linux/docker-compose.yml index da471514fc..d24b42934c 100644 --- a/docker/linux/docker-compose.yml +++ b/docker/linux/docker-compose.yml @@ -31,7 +31,8 @@ services: build: context: ./stk-engine-py38 args: - baseImage: ansys/stk:latest-centos7-pybase + baseImage: ansys/stk:latest-centos7 + basePythonImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE @@ -43,7 +44,8 @@ services: build: context: ./stk-engine-py39 args: - baseImage: ansys/stk:latest-centos7-pybase + baseImage: ansys/stk:latest-centos7 + basePythonImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE @@ -55,6 +57,7 @@ services: build: context: ./stk-engine-py310 args: - baseImage: ansys/stk:latest-centos7-pybase + baseImage: ansys/stk:latest-centos7 + basePythonImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py310/Dockerfile b/docker/linux/stk-engine-py310/Dockerfile index 3518bd0379..701ab26686 100644 --- a/docker/linux/stk-engine-py310/Dockerfile +++ b/docker/linux/stk-engine-py310/Dockerfile @@ -1,6 +1,7 @@ # By default, start from the base STK Engine Python image -ARG baseImage=ansys/stk:latest-centos7-pybase -FROM ${baseImage} as builder +ARG baseImage=ansys/stk:latest-centos7 +ARG basePythonImage=ansys/stk:latest-centos7-pybase +FROM ${basePythonImage} as builder ############################################## # 1) Build Python into its own builder stage @@ -21,10 +22,12 @@ RUN cd /tmp && \ ############################################################# # Switch back to non-root user -ARG baseImage=ansys/stk:latest-centos7 FROM ${baseImage} +USER root +# Copy the Python interpreter, the standard library and pip to the final image COPY --from=builder /usr/local/bin/python3.10 /usr/local/bin/python3.10 +COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10 COPY --from=builder /usr/local/bin/pip3.10 /usr/local/bin/pip3.10 RUN ln -sfn /usr/local/bin/python3.10 /usr/bin/python && \ diff --git a/docker/linux/stk-engine-py310/docker-compose.yml b/docker/linux/stk-engine-py310/docker-compose.yml index 6d27a6dbe1..d227e6d29e 100644 --- a/docker/linux/stk-engine-py310/docker-compose.yml +++ b/docker/linux/stk-engine-py310/docker-compose.yml @@ -6,6 +6,7 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7-pybase + baseImage: ansys/stk:latest-centos7 + basePythonImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py38/Dockerfile b/docker/linux/stk-engine-py38/Dockerfile index bbdb47f033..7683260251 100644 --- a/docker/linux/stk-engine-py38/Dockerfile +++ b/docker/linux/stk-engine-py38/Dockerfile @@ -1,6 +1,7 @@ # By default, start from the base STK Engine Python image -ARG baseImage=ansys/stk:latest-centos7-pybase -FROM ${baseImage} as builder +ARG baseImage=ansys/stk:latest-centos7 +ARG basePythonImage=ansys/stk:latest-centos7-pybase +FROM ${basePythonImage} as builder ############################################## # 1) Build Python into its own builder stage @@ -21,10 +22,12 @@ RUN cd /tmp && \ ############################################################# # Switch back to non-root user -ARG baseImage=ansys/stk:latest-centos7 FROM ${baseImage} +USER root +# Copy the Python interpreter, the standard library and pip to the final image COPY --from=builder /usr/local/bin/python3.8 /usr/local/bin/python3.8 +COPY --from=builder /usr/local/lib/python3.8 /usr/local/lib/python3.8 COPY --from=builder /usr/local/bin/pip3.8 /usr/local/bin/pip3.8 RUN ln -sfn /usr/local/bin/python3.8 /usr/bin/python && \ diff --git a/docker/linux/stk-engine-py38/docker-compose.yml b/docker/linux/stk-engine-py38/docker-compose.yml index c5a5da8699..bea1591982 100644 --- a/docker/linux/stk-engine-py38/docker-compose.yml +++ b/docker/linux/stk-engine-py38/docker-compose.yml @@ -6,6 +6,9 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7-pybase + baseImage: ansys/stk:latest-centos7 + basePythonImage: ansys/stk:latest-centos7-pybase + environment: + - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE diff --git a/docker/linux/stk-engine-py39/Dockerfile b/docker/linux/stk-engine-py39/Dockerfile index f47dce5fef..6cd5d05eb1 100644 --- a/docker/linux/stk-engine-py39/Dockerfile +++ b/docker/linux/stk-engine-py39/Dockerfile @@ -1,6 +1,7 @@ # By default, start from the base STK Engine Python image -ARG baseImage=ansys/stk:latest-centos7-pybase -FROM ${baseImage} as builder +ARG baseImage=ansys/stk:latest-centos7 +ARG basePythonImage=ansys/stk:latest-centos7-pybase +FROM ${basePythonImage} as builder ############################################## # 1) Build Python into its own builder stage @@ -21,10 +22,12 @@ RUN cd /tmp && \ ############################################################# # Switch back to non-root user -ARG baseImage=ansys/stk:latest-centos7 FROM ${baseImage} +USER root +# Copy the Python interpreter, the standard library and pip to the final image COPY --from=builder /usr/local/bin/python3.9 /usr/local/bin/python3.9 +COPY --from=builder /usr/local/lib/python3.9 /usr/local/lib/python3.9 COPY --from=builder /usr/local/bin/pip3.9 /usr/local/bin/pip3.9 RUN ln -sfn /usr/local/bin/python3.9 /usr/bin/python && \ diff --git a/docker/linux/stk-engine-py39/docker-compose.yml b/docker/linux/stk-engine-py39/docker-compose.yml index b2f2269dc0..f0e3cf865f 100644 --- a/docker/linux/stk-engine-py39/docker-compose.yml +++ b/docker/linux/stk-engine-py39/docker-compose.yml @@ -6,6 +6,7 @@ services: build: context: . args: - baseImage: ansys/stk:latest-centos7-pybase + baseImage: ansys/stk:latest-centos7 + basePythonImage: ansys/stk:latest-centos7-pybase environment: - ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE From ed4573282d1a342482d0c27d5f3e76dc3eedfba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADnez?= <28702884+jorgepiloto@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:24:54 +0100 Subject: [PATCH 18/18] DOC: fix typo Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> --- docker/linux/stk-engine/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/linux/stk-engine/Dockerfile b/docker/linux/stk-engine/Dockerfile index b94b1bdf38..0a9c8eef40 100644 --- a/docker/linux/stk-engine/Dockerfile +++ b/docker/linux/stk-engine/Dockerfile @@ -23,7 +23,7 @@ RUN set -e; \ # Set the base image for the next stage FROM ${baseImage} -LABEL ANSYSLMD_LICENSE_FILE='Specifies the location of the Ansys Licensing Server. The format should be PORT@FQDN. If using a triad of license server, list all servers in the same format separated by semicolons. Required.' +LABEL ANSYSLMD_LICENSE_FILE='Specifies the location of the Ansys Licensing Server. The format should be PORT@FQDN. If using a triad of license servers, list all servers in the same format separated by semicolons. Required.' # Define STK user home directory ENV STK_USER_HOME=/home/stk