├── requirements.txt ├── .gitignore ├── tpls ├── tpl.docker-compose.test.yml ├── tpl.post_push ├── tpl.README.md └── tpl.Dockerfile ├── configs └── intelpython3_full │ ├── docker-compose.test.yml │ ├── hooks │ └── post_push │ ├── README.md │ └── Dockerfile ├── SECURITY.md ├── .github └── workflows │ ├── ci.yml │ ├── publish.yml │ └── scorecard.yml ├── LICENSE ├── tests └── test_images.py ├── README.md └── images.py /requirements.txt: -------------------------------------------------------------------------------- 1 | jinja2 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /tpls/tpl.docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | sut: 2 | build: . 3 | command: python -c "import scipy" 4 | -------------------------------------------------------------------------------- /configs/intelpython3_full/docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | sut: 2 | build: . 3 | command: python -c "import scipy" -------------------------------------------------------------------------------- /configs/intelpython3_full/hooks/post_push: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_REPO:2021.4 4 | docker push $DOCKER_REPO:2021.4 5 | 6 | docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_REPO:latest 7 | docker push $DOCKER_REPO:latest -------------------------------------------------------------------------------- /tpls/tpl.post_push: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_REPO:{{update_number}} 4 | docker push $DOCKER_REPO:{{update_number}} 5 | 6 | docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_REPO:latest 7 | docker push $DOCKER_REPO:latest 8 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. 3 | 4 | ## Reporting a Vulnerability 5 | Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | # Declare default permissions as read only. 4 | permissions: read-all 5 | 6 | defaults: 7 | run: 8 | shell: bash 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | include: 17 | - IDP_CONF: intelpython3_full 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-python@v2 21 | with: 22 | python-version: '3.x' 23 | - name: Install Dependencies 24 | run: | 25 | pip install -r requirements.txt 26 | - name: Build and test 27 | run: | 28 | python images.py --test ${{ matrix.IDP_CONF }} 29 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish on Docker Hub 2 | 3 | # Declare default permissions as read only. 4 | permissions: read-all 5 | 6 | on: 7 | push: 8 | tags: 9 | - '*' 10 | 11 | jobs: 12 | push_to_registry: 13 | name: Push Docker image to Docker Hub 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Check out the repo 17 | uses: actions/checkout@v2 18 | 19 | - name: Log in to Docker Hub 20 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 21 | with: 22 | username: ${{ secrets.DOCKER_LOGIN_USERNAME }} 23 | password: ${{ secrets.DOCKER_LOGIN_PASSWORD }} 24 | 25 | - name: Extract intelpython3_full metadata (tags, labels) for Docker 26 | id: meta_full 27 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 28 | with: 29 | images: intelpython/intelpython3_full 30 | 31 | - name: Build and push Docker image for intelpython3_full 32 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 33 | with: 34 | context: configs/intelpython3_full 35 | push: true 36 | tags: ${{ steps.meta_full.outputs.tags }} 37 | labels: ${{ steps.meta_full.outputs.labels }} 38 | -------------------------------------------------------------------------------- /tpls/tpl.README.md: -------------------------------------------------------------------------------- 1 | Docker images for [Intel Distribution for Python](https://www.intel.com/content/www/us/en/developer/tools/oneapi/distribution-for-python.html) 2 | 3 | The image defaults to starting with a bash shell. Intel Python is on the path. There is 1 image for every install configuration. 4 | 5 | Images: 6 | 7 | * intelpython3_full 8 | 9 | You usually want the 'latest' tag, but the docker image tag can be used to request a specific package. For example: 10 | 11 | docker pull intelpython3_full:2017.0.3-1 12 | 13 | Will get an image that uses the conda package: intelpython3_full-2017.0.3-1 14 | 15 | Tags: 16 | 17 | * 2020.0 18 | * 2019.5 19 | * 2019.4 20 | * 2019.3 21 | * 2019.1-0 22 | * 2019.0.0-0b, 2019.0.0-0a, 2019.0.0-0, 2019.0.0 23 | * 2018.0.3 24 | * 2018.0.2 25 | * 2018.0.1-0, 2018.0.1 26 | * 2018.0.0-0, 2018.0.0 27 | * 2017.0.3-3, 2017.0.3 28 | * 2017.0.3-1 29 | * 2017.0.3-0 30 | * 2017.0.2-0, 2017.0.2 31 | * 2017.0.1-1, 2017.0.1 32 | * 2017.0.0-2, 2017.0.0 33 | 34 | LEGAL NOTICE: By accessing, downloading or using this software and any required dependent software (the "Software Package"), you agree to the terms and conditions of the software license agreements for the Software Package, which may also include notices, disclaimers, or license terms for third party software included with the Software Package. Please refer to the "third-party-programs.txt" or other similarly-named text file for additional details. 35 | -------------------------------------------------------------------------------- /configs/intelpython3_full/README.md: -------------------------------------------------------------------------------- 1 | Docker images for [Intel Distribution for Python](https://www.intel.com/content/www/us/en/developer/tools/oneapi/distribution-for-python.html) 2 | 3 | The image defaults to starting with a bash shell. Intel Python is on the path. There is 1 image for every install configuration. 4 | 5 | Images: 6 | 7 | * intelpython3_full 8 | 9 | You usually want the 'latest' tag, but the docker image tag can be used to request a specific package. For example: 10 | 11 | docker pull intelpython3_full:2017.0.3-1 12 | 13 | Will get an image that uses the conda package: intelpython3_full-2017.0.3-1 14 | 15 | Tags: 16 | 17 | * 2020.0 18 | * 2019.5 19 | * 2019.4 20 | * 2019.3 21 | * 2019.1-0 22 | * 2019.0.0-0b, 2019.0.0-0a, 2019.0.0-0, 2019.0.0 23 | * 2018.0.3 24 | * 2018.0.2 25 | * 2018.0.1-0, 2018.0.1 26 | * 2018.0.0-0, 2018.0.0 27 | * 2017.0.3-3, 2017.0.3 28 | * 2017.0.3-1 29 | * 2017.0.3-0 30 | * 2017.0.2-0, 2017.0.2 31 | * 2017.0.1-1, 2017.0.1 32 | * 2017.0.0-2, 2017.0.0 33 | 34 | LEGAL NOTICE: By accessing, downloading or using this software and any required dependent software (the "Software Package"), you agree to the terms and conditions of the software license agreements for the Software Package, which may also include notices, disclaimers, or license terms for third party software included with the Software Package. Please refer to the "third-party-programs.txt" or other similarly-named text file for additional details. 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Intel Corporation 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # * Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of Intel Corporation nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /configs/intelpython3_full/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Intel Corporation 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # * Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of Intel Corporation nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | FROM condaforge/mambaforge 27 | 28 | RUN conda config --add channels https://software.repos.intel.com/python/conda 29 | RUN conda config --add channels conda-forge 30 | RUN conda install -y -q intelpython3_full=2025.0 python=3.12 31 | RUN conda clean --all 32 | -------------------------------------------------------------------------------- /tests/test_images.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Intel Corporation 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # * Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of Intel Corporation nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | import getpass 27 | import os 28 | import subprocess 29 | 30 | def test_gen(): 31 | subprocess.check_call('python images.py --gen all', shell=True) 32 | def test_build(): 33 | subprocess.check_call('python images.py --build all', shell=True) 34 | def test_test(): 35 | subprocess.check_call('python images.py --test all', shell=True) 36 | -------------------------------------------------------------------------------- /tpls/tpl.Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Intel Corporation 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # * Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of Intel Corporation nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | FROM continuumio/miniconda3:4.7.12 27 | MAINTAINER Robert Cohn 28 | 29 | # This file is automatically generated from tpl.Dockerfile 30 | 31 | ENV ACCEPT_INTEL_PYTHON_EULA=yes 32 | 33 | RUN conda config --add channels intel 34 | RUN conda install {{install_args}} -y -q intelpython{{pyver}}_{{package}}={{update_number}}{{build_number}} python={{pyver}} 35 | RUN conda clean --all 36 | 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # container-images 2 | 3 | [![.github/workflows/ci.yml](https://github.com/IntelPython/container-images/actions/workflows/ci.yml/badge.svg)](https://github.com/IntelPython/container-images/actions/workflows/ci.yml) 4 | 5 | Dockerfiles and build contexts for building docker images 6 | 7 | There is 1 subdirectory for every image to build. Dockerfiles and build 8 | contexts are generated from jinja2 templates in tpls directory. The images.py 9 | script generates the files, and can also be used to build docker images and to 10 | test them. To see more info do: 11 | 12 | python images.py --help 13 | 14 | ## testing 15 | 16 | python -m pytest tests 17 | 18 | Will build every image. Look at the test for example command lines. 19 | 20 | ## Adding an image 21 | 22 | * copy one of the the existing directories 23 | * See images.py for directions on adding a new configuration 24 | * create a new automated build on docker hub, copying build setting of existing image 25 | 26 | ## Publishing a new release (Internal Use Only) 27 | 28 | Disclaimer: Do NOT do this unless all packages for upcoming release have been 29 | uploaded to Intel channel on Anaconda Cloud. Best time to do this is right before 30 | FCS when all packages have automatically been uploaded and validated. 31 | 32 | If we are publishing 2017.0.0 build number 2, then the docker image will have 3 33 | tags: 2017.0.0-2, 2017.0.0, latest. Github Actions will create a Docker image 34 | after a PR is merged. The following steps are all that is needed to update our 35 | Dockerhub with our latest IntelPython. 36 | 37 | * Change update_number & build_number in images.py. Most of the time, the build number 38 | remains the same (#0) and the minor version is incremented (e.g. 2021.1.0 -> 2021.2.0) 39 | * Regenerate the READMEs and Dockerfiles for the individual images by running the following 40 | command 41 | 42 | python images.py --gen all 43 | 44 | * Create branch and commit changes 45 | * Tag with the release name 46 | 47 | git tag -a 2022.0.0-0 -m '2022.0.0-0 release' 48 | git push origin update/2022.0.0-0 49 | git push origin 2022.0.0-0 50 | 51 | * Create PR, check that tests pass, and then merge PR. Github actions has been setup to 52 | automatically build the Docker image and push it to Dockerhub afterwards. 53 | -------------------------------------------------------------------------------- /.github/workflows/scorecard.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. They are provided 2 | # by a third-party and are governed by separate terms of service, privacy 3 | # policy, and support documentation. 4 | 5 | name: Scorecard supply-chain security 6 | on: 7 | # For Branch-Protection check. Only the default branch is supported. See 8 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection 9 | branch_protection_rule: 10 | # To guarantee Maintained check is occasionally updated. See 11 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained 12 | schedule: 13 | - cron: '44 22 * * 5' 14 | push: 15 | branches: [ "master" ] 16 | 17 | # Declare default permissions as read only. 18 | permissions: read-all 19 | 20 | jobs: 21 | analysis: 22 | name: Scorecard analysis 23 | runs-on: ubuntu-latest 24 | permissions: 25 | # Needed to upload the results to code-scanning dashboard. 26 | security-events: write 27 | # Needed to publish results and get a badge (see publish_results below). 28 | id-token: write 29 | # Uncomment the permissions below if installing in a private repository. 30 | # contents: read 31 | # actions: read 32 | 33 | steps: 34 | - name: "Checkout code" 35 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 36 | with: 37 | persist-credentials: false 38 | 39 | - name: "Run analysis" 40 | uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 41 | with: 42 | results_file: results.sarif 43 | results_format: sarif 44 | # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: 45 | # - you want to enable the Branch-Protection check on a *public* repository, or 46 | # - you are installing Scorecard on a *private* repository 47 | # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional. 48 | # repo_token: ${{ secrets.SCORECARD_TOKEN }} 49 | 50 | # Public repositories: 51 | # - Publish results to OpenSSF REST API for easy access by consumers 52 | # - Allows the repository to include the Scorecard badge. 53 | # - See https://github.com/ossf/scorecard-action#publishing-results. 54 | # For private repositories: 55 | # - `publish_results` will always be set to `false`, regardless 56 | # of the value entered here. 57 | publish_results: true 58 | 59 | # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF 60 | # format to the repository Actions tab. 61 | # - name: "Upload artifact" 62 | # uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20 63 | # with: 64 | # name: SARIF file 65 | # path: results.sarif 66 | # retention-days: 5 67 | 68 | # # Upload the results to GitHub's code scanning dashboard (optional). 69 | # # Commenting out will disable upload of results to your repo's Code Scanning dashboard 70 | # - name: "Upload to code-scanning" 71 | # uses: github/codeql-action/upload-sarif@v3 72 | # with: 73 | # sarif_file: results.sarif 74 | -------------------------------------------------------------------------------- /images.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Intel Corporation 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # * Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of Intel Corporation nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | from __future__ import print_function 27 | 28 | import argparse 29 | import getpass 30 | import jinja2 31 | import os 32 | import re 33 | import subprocess 34 | import sys 35 | 36 | 37 | def get_proxies(): 38 | '''Pass through proxies to docker container''' 39 | proxies = '' 40 | for var in ['http_proxy','https_proxy','socks_proxy','ftp_proxy','no_proxy']: 41 | if var in os.environ: 42 | proxies += ' --build-arg %s=%s' % (var,os.environ[var]) 43 | return proxies 44 | 45 | class Templates(): 46 | '''singleton to render the templates''' 47 | def __init__(self): 48 | loader = jinja2.FileSystemLoader(searchpath = 'tpls') 49 | env = jinja2.Environment(loader=loader) 50 | self._readme = env.get_template('tpl.README.md') 51 | self._dockerfile = env.get_template('tpl.Dockerfile') 52 | self._post_push = env.get_template('tpl.post_push') 53 | self._test = env.get_template('tpl.docker-compose.test.yml') 54 | 55 | def render(self, conf): 56 | name = conf.name() 57 | with open('configs/%s/README.md' % name,'wb') as fh: 58 | fh.write(self._readme.render(conf).encode('utf-8')) 59 | with open('configs/%s/Dockerfile' % name,'wb') as fh: 60 | fh.write(self._dockerfile.render(conf).encode('utf-8')) 61 | with open('configs/%s/docker-compose.test.yml' % name,'wb') as fh: 62 | fh.write(self._test.render(conf).encode('utf-8')) 63 | with open('configs/%s/hooks/post_push' % name,'wb') as fh: 64 | fh.write(self._post_push.render(conf).encode('utf-8')) 65 | 66 | # singleton 67 | templates = Templates() 68 | 69 | def parse_name(name): 70 | pattern = re.compile(r'intelpython(?P[23])_(?P.*)') 71 | match = pattern.match(name) 72 | return (int(match.group('pyver')),match.group('package')) 73 | 74 | class Conf(dict): 75 | '''Docker image configuration''' 76 | def __init__(self,pyver=None,package=None,build_number=None,name=None): 77 | if name: 78 | (pyver,package) = parse_name(name) 79 | self['pyver'] = pyver 80 | self['package'] = package 81 | # github tag & docker tag is update_number-build_number, e.g. 2017.0.1-1 82 | # conda package spec is update_number=build_number, e.g. intelpython2_core=2017.0.1=1 83 | self['update_number'] = '2021.4' 84 | if build_number: 85 | self['build_number'] = '=' + str(build_number) 86 | 87 | def name(self): 88 | return 'intelpython%d_%s' % (self['pyver'],self['package']) 89 | 90 | def tag(self): 91 | return '%s/%s' % (getpass.getuser(),self.name()) 92 | 93 | def gen(self): 94 | templates.render(self) 95 | 96 | def build(self): 97 | cmd = 'docker build %s -t %s --file configs/%s/Dockerfile configs/%s' % (get_proxies(),self.tag(),self.name(),self.name()) 98 | print(' ',cmd) 99 | subprocess.check_call(cmd, shell=True) 100 | 101 | def test(self): 102 | cmd = 'docker run -t %s python -c 1' % self.tag() 103 | print(' ',cmd) 104 | subprocess.check_call(cmd, shell=True) 105 | 106 | # Add new configurations here 107 | all_confs = [Conf(3,'core',0), 108 | Conf(3,'full',0) 109 | ] 110 | 111 | def get_conf(name): 112 | for c in all_confs: 113 | if c.name() == name: 114 | return c 115 | print('Could not find conf: ',name) 116 | return None 117 | 118 | def main(): 119 | conf_names = [conf.name() for conf in all_confs] 120 | parser = argparse.ArgumentParser(description='generate the configurations for docker images') 121 | parser.add_argument('--gen', 122 | action='store_true', 123 | help='Generate Dockerfile and README.md') 124 | parser.add_argument('--build', 125 | action='store_true', 126 | help='Build docker image') 127 | parser.add_argument('--test', 128 | action='store_true', 129 | help='Test docker image') 130 | parser.add_argument('--install-args', 131 | help='extra args for conda install') 132 | parser.add_argument('conf', 133 | choices=['all'] + conf_names, 134 | nargs='*', 135 | help='list of confs to generate') 136 | args = parser.parse_args() 137 | if args.conf[0] == 'all': 138 | args.conf = conf_names 139 | 140 | for n in args.conf: 141 | print('Processing:',n) 142 | c = get_conf(n) 143 | if args.install_args: 144 | c['install_args'] = args.install_args 145 | if args.gen: 146 | print(' gen') 147 | c.gen() 148 | if args.build | args.test: 149 | print(' build') 150 | c.build() 151 | if args.test: 152 | print(' test') 153 | c.test() 154 | 155 | 156 | main() 157 | --------------------------------------------------------------------------------