make docker a python (2+3) script

This commit is contained in:
Guillaume Leclerc 2016-05-14 23:30:19 +02:00
parent 1b3a59e106
commit 36da7fac39
2 changed files with 37 additions and 11 deletions

View file

@ -1,11 +0,0 @@
from python:3
RUN pip install --upgrade pip && pip install \
ply \
prompt-toolkit \
pygments
RUN mkdir /xonsh
WORKDIR /xonsh
ADD ./ ./
RUN python setup.py install
CMD /usr/bin/env xonsh
ENV XONSH_COLOR_STYLE "paraiso-dark"

37
docker.py Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
import sys
import subprocess
import os
pythonVersion = '3.5'
ptkVersion = '1.00'
if len(sys.argv) > 1:
pythonVersion = sys.argv[1]
if len(sys.argv) > 2:
ptkVersion = sys.argv[2]
print('Building and runing Xonsh')
print('Using python ', pythonVersion)
print('Using prompt-toolkit ', ptkVersion)
dockerFile = 'from python:'+pythonVersion + '\n'
dockerFile += 'RUN pip install --upgrade pip && pip install \\\n'
dockerFile += ' ply \\\n'
dockerFile += ' prompt-toolkit=='+ptkVersion+ ' \\\n'
dockerFile += ' pygments\n'
dockerFile += 'RUN mkdir /xonsh\n'
dockerFile += 'WORKDIR /xonsh\n'
dockerFile += 'CMD /usr/bin/env xonsh\n'
dockerFile += 'ENV XONSH_COLOR_STYLE "paraiso-dark\n'
dockerFile += 'ADD ./ ./\n'
dockerFile += 'RUN python setup.py install\n'
with open('./Dockerfile', 'w+') as f:
f.write(dockerFile)
subprocess.call(['docker', 'build', '-t' , 'xonsh', '.'])
os.remove('./Dockerfile')
subprocess.call(['docker', 'run', '-ti' , 'xonsh'])