-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile.mako
58 lines (48 loc) · 1.81 KB
/
Dockerfile.mako
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<%
import os, os.path, collections
packages = sorted(filter(lambda p: os.path.isdir(os.path.join('package', p)), os.listdir('package')))
pdict = collections.OrderedDict()
prepfiles = []
debpackages = ['git', 'mc', 'build-essential', 'python-dev', 'python-virtualenv']
for p in packages:
obj = collections.OrderedDict()
pdict[p] = obj
dpath = os.path.join('.', 'package', p, 'docker')
if not os.path.isdir(dpath):
continue
obj['source_path'] = dpath
obj['build_path'] = os.path.join('build', p)
obj['requirements'] = os.path.isfile(os.path.join(dpath, 'requirements'))
obj['envsetup'] = os.path.isfile(os.path.join(dpath, 'envsetup.dockerfile'))
pdfile = os.path.join(dpath, 'prepeare.dockerfile')
if os.path.isfile(pdfile):
with open(pdfile, 'r') as fd:
prepfiles.append('# Package ' + p)
prepfiles.append(fd.read())
dpfile = os.path.join(dpath, 'debpackages')
if os.path.isfile(dpfile):
with open(dpfile, 'r') as fd:
debpackages.append(fd.read())
%>
FROM ubuntu:16.04
RUN mkdir /build /src /src/package
${'\n'.join(prepfiles)}
# Update repositories & install packages
RUN apt-get update && apt-get install -y ${' '.join(debpackages)}
# Setup virtualenv
RUN /usr/bin/virtualenv /env && /env/bin/pip install --upgrade pip
%for package, pdef in pdict.iteritems():
# Package ${package}
ADD ${pdef['source_path']} ${pdef['build_path']}
%if pdef['requirements']:
RUN /env/bin/pip install -r ${pdef['build_path']}/requirements
%endif
%if pdef['envsetup']:
<% with open(os.path.join(pdef['source_path'], 'envsetup.dockerfile'), 'r') as fd: inccont = fd.read() %>${inccont}
%endif
%endfor
ADD ./package /src/package
%for package in packages:
RUN echo ${package} >> /build/package
RUN /env/bin/pip install -e /src/package/${package}
%endfor