dockerize
This commit is contained in:
parent
ed645ac002
commit
1c56f09ddb
|
@ -0,0 +1,4 @@
|
||||||
|
/iso_raws/*
|
||||||
|
/isos/ubuntu-*
|
||||||
|
*.iso
|
||||||
|
/testenv
|
|
@ -0,0 +1,6 @@
|
||||||
|
.DS_Store
|
||||||
|
*.iso
|
||||||
|
/isos/ubuntu-*
|
||||||
|
/isoserver.egg-info/
|
||||||
|
/testenv/
|
||||||
|
__pycache__
|
|
@ -0,0 +1,12 @@
|
||||||
|
FROM ubuntu:bionic
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y python3-pip bsdtar genisoimage
|
||||||
|
|
||||||
|
ADD . /tmp/code
|
||||||
|
|
||||||
|
RUN cd /tmp/code && \
|
||||||
|
pip3 install -r requirements.txt && \
|
||||||
|
python3 setup.py install && \
|
||||||
|
mkdir /data
|
||||||
|
|
||||||
|
ENTRYPOINT ["isoserverd"]
|
|
@ -57,3 +57,11 @@ Installing the `system-config-kickstart` provides a tool for generating Kickstar
|
||||||
apt-get install system-config-kickstart
|
apt-get install system-config-kickstart
|
||||||
system-config-kickstart
|
system-config-kickstart
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Docker
|
||||||
|
------
|
||||||
|
|
||||||
|
Run the image like:
|
||||||
|
|
||||||
|
* `docker run -it --rm -e PORT=8080 -v /host/iso_raws:/data kickstart`
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
*
|
|
|
@ -79,7 +79,7 @@ set +x
|
||||||
sed -i -E "s/^#?PermitRootLogin .+/PermitRootLogin yes/" /etc/ssh/sshd_config
|
sed -i -E "s/^#?PermitRootLogin .+/PermitRootLogin yes/" /etc/ssh/sshd_config
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get dist-upgrade -y
|
apt-get dist-upgrade -y
|
||||||
apt-get install -y open-vm-tools
|
apt-get install -y open-vm-tools dirmngr
|
||||||
rm /etc/firstboot
|
rm /etc/firstboot
|
||||||
reboot
|
reboot
|
||||||
EOF
|
EOF
|
|
@ -7,31 +7,41 @@ from threading import Semaphore
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
APPROOT = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
|
||||||
class ISOserver(object):
|
class ISOserver(object):
|
||||||
def __init__(self):
|
def __init__(self, isodir):
|
||||||
self.data_dir = "./iso_raws"
|
self.data_dir = isodir
|
||||||
self.iso_selection = [i for i in os.listdir(self.data_dir) if not i.startswith(".")]
|
self.iso_selection = [i for i in os.listdir(self.data_dir) if not any([i.startswith("."), i == "samples"])]
|
||||||
|
if not self.iso_selection:
|
||||||
|
raise Exception("No base isos found in path {}".format(self.data_dir))
|
||||||
|
|
||||||
self.builder_semaphores = {i: Semaphore() for i in self.iso_selection}
|
self.builder_semaphores = {i: Semaphore() for i in self.iso_selection}
|
||||||
self._load_templates()
|
self._load_templates()
|
||||||
|
|
||||||
def _load_templates(self):
|
def _load_templates(self):
|
||||||
with open("./main.html") as template_f:
|
with open(os.path.join(APPROOT, "main.html")) as template_f:
|
||||||
self.template = Environment(autoescape=True).from_string(template_f.read())
|
self.template = Environment(autoescape=True).from_string(template_f.read())
|
||||||
|
|
||||||
samples = os.listdir("samples")
|
basedir = os.path.join(self.data_dir, "samples")
|
||||||
|
os.makedirs(basedir, exist_ok=True)
|
||||||
|
samples = os.listdir(basedir)
|
||||||
|
if not samples:
|
||||||
|
raise Exception("No templates found in path {}".format(basedir))
|
||||||
self.samples = {}
|
self.samples = {}
|
||||||
|
|
||||||
for item in samples:
|
for item in samples:
|
||||||
self.samples[item] = {}
|
self.samples[item] = {}
|
||||||
with open(os.path.join("samples", item, "menu.default")) as f:
|
with open(os.path.join(basedir, item, "menu.default")) as f:
|
||||||
self.samples[item]["MENU_ENTRIES"] = f.read()
|
self.samples[item]["MENU_ENTRIES"] = f.read()
|
||||||
with open(os.path.join("samples", item, "seed.default")) as f:
|
with open(os.path.join(basedir, item, "seed.default")) as f:
|
||||||
self.samples[item]["SEED_CONTENT"] = f.read()
|
self.samples[item]["SEED_CONTENT"] = f.read()
|
||||||
with open(os.path.join("samples", item, "ks.default")) as f:
|
with open(os.path.join(basedir, item, "ks.default")) as f:
|
||||||
self.samples[item]["KS_CONTENT"] = f.read()
|
self.samples[item]["KS_CONTENT"] = f.read()
|
||||||
info_path = os.path.join("samples", item, "info.txt")
|
info_path = os.path.join(basedir, item, "info.txt")
|
||||||
if os.path.exists(info_path):
|
if os.path.exists(info_path):
|
||||||
with open(os.path.join("samples", item, "info.txt")) as f:
|
with open(os.path.join(basedir, item, "info.txt")) as f:
|
||||||
self.samples[item]["SAMPLE_INFO"] = f.read()
|
self.samples[item]["SAMPLE_INFO"] = f.read()
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
|
@ -115,26 +125,28 @@ class ISOserver(object):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
import logging
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
parser = ArgumentParser()
|
||||||
|
parser.add_argument("-p", "--port", help="listen port", default=int(os.environ.get("PORT", 8087)))
|
||||||
|
parser.add_argument("-d", "--data", help="iso data folder", default=os.environ.get("DATADIR", "/data"))
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
cherrypy.tree.mount(ISOserver(args.data), '/', config={})
|
||||||
|
|
||||||
cherrypy.config.update({
|
cherrypy.config.update({
|
||||||
'engine.autoreload_on': False,
|
'environment': 'production',
|
||||||
'tools.sessions.on': False,
|
|
||||||
'tools.sessions.storage_type': 'ram', # 'file',
|
|
||||||
'tools.sessions.timeout': 525600,
|
|
||||||
'server.show.tracebacks': True,
|
|
||||||
'server.socket_port': 8087,
|
|
||||||
'server.thread_pool': 10,
|
|
||||||
'server.socket_host': '0.0.0.0',
|
'server.socket_host': '0.0.0.0',
|
||||||
# 'tools.sessions.storage_path': './sessions/',
|
'server.socket_port': args.port,
|
||||||
'tools.sessions.locking': 'explicit' # cherrypy.session.acquire_lock() cherrypy.session.release_lock()
|
'tools.sessions.on': False,
|
||||||
|
'server.thread_pool': 10,
|
||||||
})
|
})
|
||||||
|
|
||||||
cherrypy.tree.mount(ISOserver(), '/', config={
|
|
||||||
'/': {},
|
|
||||||
'/static': { # 'tools.staticdir.on': True,
|
|
||||||
# 'tools.staticdir.dir': ./static/"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
cherrypy.engine.start()
|
cherrypy.engine.start()
|
||||||
cherrypy.engine.block()
|
cherrypy.engine.block()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
|
@ -1,11 +1,15 @@
|
||||||
appdirs==1.4.3
|
appdirs==1.4.3
|
||||||
cheroot==5.5.0
|
backports.functools-lru-cache==1.5
|
||||||
CherryPy==10.2.2
|
cheroot==6.5.4
|
||||||
|
CherryPy==18.1.1
|
||||||
|
jaraco.functools==2.0
|
||||||
Jinja2==2.9.6
|
Jinja2==2.9.6
|
||||||
MarkupSafe==1.0
|
MarkupSafe==1.0
|
||||||
|
more-itertools==7.0.0
|
||||||
packaging==16.8
|
packaging==16.8
|
||||||
portend==1.8
|
portend==2.4
|
||||||
pyparsing==2.2.0
|
pyparsing==2.2.0
|
||||||
pytz==2017.2
|
pytz==2017.2
|
||||||
six==1.10.0
|
six==1.12.0
|
||||||
tempora==1.7
|
tempora==1.14
|
||||||
|
zc.lockfile==1.4
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
__version__ = "0.0.1"
|
||||||
|
|
||||||
|
setup(name='isoserver',
|
||||||
|
version=__version__,
|
||||||
|
description='',
|
||||||
|
url='http://git.davepedu.com/dave/kickstart-builder',
|
||||||
|
author='dpedu',
|
||||||
|
author_email='dave@davepedu.com',
|
||||||
|
packages=['isoserver'],
|
||||||
|
entry_points={
|
||||||
|
"console_scripts": [
|
||||||
|
"isoserverd = isoserver:main"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
include_package_data=True,
|
||||||
|
package_data={'isoserver': ['main.html']},
|
||||||
|
zip_safe=False)
|
Loading…
Reference in New Issue