Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 89e7923

Browse files
committed
refactor, rename images, install in root conda env
1 parent 9ec2055 commit 89e7923

File tree

19 files changed

+276
-56
lines changed

19 files changed

+276
-56
lines changed

.travis.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
language: python
22

33
env:
4-
- SELECT_BUILDS=idp2_core
5-
- SELECT_BUILDS=idp3_core
6-
- SELECT_BUILDS=idp2_full
7-
- SELECT_BUILDS=idp3_full
4+
- IDP_CONF=intelpython2_core
5+
- IDP_CONF=intelpython2_full
6+
- IDP_CONF=intelpython3_core
7+
- IDP_CONF=intelpython3_full
88

99
sudo: required
1010

1111
services:
1212
- docker
1313

1414
script:
15-
- python -m pytest tests
16-
17-
branches:
18-
only:
19-
- master
15+
- python images.py --test $IDP_CONF

docker_repo.README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

images.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import argparse
2+
import getpass
3+
import jinja2
4+
import os
5+
import re
6+
import subprocess
7+
import sys
8+
9+
def get_proxies():
10+
'''Pass through proxies to docker container'''
11+
proxies = ''
12+
for var in ['http_proxy','https_proxy','no_proxy']:
13+
if var in os.environ:
14+
proxies += ' --build-arg %s=%s' % (var,os.environ[var])
15+
return proxies
16+
17+
class Templates():
18+
'''singleton to render the templates'''
19+
def __init__(self):
20+
loader = jinja2.FileSystemLoader(searchpath = '.')
21+
env = jinja2.Environment(loader=loader)
22+
self._readme = env.get_template('tpl.README.md')
23+
self._dockerfile = env.get_template('tpl.Dockerfile')
24+
25+
def render(self, conf):
26+
name = conf.name()
27+
with open('%s/README.md' % name,'wb') as fh:
28+
fh.write(self._readme.render(conf).encode('utf-8'))
29+
with open('%s/Dockerfile' % name,'wb') as fh:
30+
fh.write(self._dockerfile.render(conf).encode('utf-8'))
31+
32+
# singleton
33+
templates = Templates()
34+
35+
def parse_name(name):
36+
pattern = re.compile(r'intelpython(?P<pyver>[23])_(?P<package>.*)')
37+
match = pattern.match(name)
38+
return (int(match.group('pyver')),match.group('package'))
39+
40+
class Conf(dict):
41+
'''Docker image configuration'''
42+
def __init__(self,pyver=None,package=None,name=None):
43+
if name:
44+
(pyver,package) = parse_name(name)
45+
self['pyver'] = pyver
46+
self['package'] = package
47+
self['release'] = '2017.0.0'
48+
49+
def name(self):
50+
return 'intelpython%d_%s' % (self['pyver'],self['package'])
51+
52+
def tag(self):
53+
return '%s/%s' % (getpass.getuser(),self.name())
54+
55+
def gen(self):
56+
templates.render(self)
57+
58+
def build(self):
59+
cmd = 'docker build %s -t %s --file %s/Dockerfile .' % (get_proxies(),self.tag(),self.name())
60+
print(' ',cmd)
61+
subprocess.check_call(cmd, shell=True)
62+
63+
def test(self):
64+
cmd = 'docker run -t %s python -c 1' % self.tag()
65+
print(' ',cmd)
66+
subprocess.check_call(cmd, shell=True)
67+
68+
all_confs = [Conf(2,'core'),
69+
Conf(2,'full'),
70+
Conf(3,'core'),
71+
Conf(3,'full')
72+
]
73+
74+
def main():
75+
conf_names = [conf.name() for conf in all_confs]
76+
parser = argparse.ArgumentParser(description='generate the configurations for docker images')
77+
parser.add_argument('--gen',
78+
action='store_true',
79+
help='Generate Dockerfile and README.md')
80+
parser.add_argument('--build',
81+
action='store_true',
82+
help='Build docker image')
83+
parser.add_argument('--test',
84+
action='store_true',
85+
help='Test docker image')
86+
parser.add_argument('conf',
87+
choices=['all'] + conf_names,
88+
nargs='*',
89+
help='list of confs to generate')
90+
args = parser.parse_args()
91+
if args.conf[0] == 'all':
92+
args.conf = conf_names
93+
94+
for n in args.conf:
95+
print('Processing:',n)
96+
c = Conf(name=n)
97+
if args.gen | args.build | args.test:
98+
print(' gen')
99+
c.gen()
100+
if args.build | args.test:
101+
print(' build')
102+
c.build()
103+
if args.test:
104+
print(' test')
105+
c.test()
106+
107+
108+
main()

intelpython2_core/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM continuumio/miniconda3:4.1.11
2+
MAINTAINER Robert Cohn <[email protected]>
3+
4+
# This file is automatically generated from tpl.Dockerfile
5+
6+
ENV ACCEPT_INTEL_PYTHON_EULA=yes
7+
8+
RUN conda config --add channels intel \
9+
&& conda install -y -q intelpython2_core=2017.0.0 python=2

intelpython2_core/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Docker images for [Intel Distribution for Python](https://software.intel.com/en-us/intel-distribution-for-python)
2+
3+
Tags:
4+
5+
* 2017.0.1, latest
6+
* 2017.0.0
7+
8+
There is 1 image for every install configuration. A conda environment called
9+
idp is created and activated.
10+
11+
Images:
12+
13+
* intelpython2_core
14+
* intelpython2_full
15+
* intelpython3_core
16+
* intelpython3_full
17+
18+
The image defaults to starting with a bash shell.
19+
20+
21+

intelpython2_full/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM continuumio/miniconda3:4.1.11
2+
MAINTAINER Robert Cohn <[email protected]>
3+
4+
# This file is automatically generated from tpl.Dockerfile
5+
6+
ENV ACCEPT_INTEL_PYTHON_EULA=yes
7+
8+
RUN conda config --add channels intel \
9+
&& conda install -y -q intelpython2_full=2017.0.0 python=2

intelpython2_full/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Docker images for [Intel Distribution for Python](https://software.intel.com/en-us/intel-distribution-for-python)
2+
3+
Tags:
4+
5+
* 2017.0.1, latest
6+
* 2017.0.0
7+
8+
There is 1 image for every install configuration. A conda environment called
9+
idp is created and activated.
10+
11+
Images:
12+
13+
* intelpython2_core
14+
* intelpython2_full
15+
* intelpython3_core
16+
* intelpython3_full
17+
18+
The image defaults to starting with a bash shell.
19+
20+
21+

intelpython3_core/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM continuumio/miniconda3:4.1.11
2+
MAINTAINER Robert Cohn <[email protected]>
3+
4+
# This file is automatically generated from tpl.Dockerfile
5+
6+
ENV ACCEPT_INTEL_PYTHON_EULA=yes
7+
8+
RUN conda config --add channels intel \
9+
&& conda install -y -q intelpython3_core=2017.0.0 python=3

intelpython3_core/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Docker images for [Intel Distribution for Python](https://software.intel.com/en-us/intel-distribution-for-python)
2+
3+
Tags:
4+
5+
* 2017.0.1, latest
6+
* 2017.0.0
7+
8+
There is 1 image for every install configuration. A conda environment called
9+
idp is created and activated.
10+
11+
Images:
12+
13+
* intelpython2_core
14+
* intelpython2_full
15+
* intelpython3_core
16+
* intelpython3_full
17+
18+
The image defaults to starting with a bash shell.
19+
20+
21+

intelpython3_full/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM continuumio/miniconda3:4.1.11
2+
MAINTAINER Robert Cohn <[email protected]>
3+
4+
# This file is automatically generated from tpl.Dockerfile
5+
6+
ENV ACCEPT_INTEL_PYTHON_EULA=yes
7+
8+
RUN conda config --add channels intel \
9+
&& conda install -y -q intelpython3_full=2017.0.0 python=3

0 commit comments

Comments
 (0)