mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-14 07:04:52 -04:00
Added new webui support into docker
This commit is contained in:
parent
ca7ba46507
commit
5674e26979
4 changed files with 22 additions and 6 deletions
|
@ -12,9 +12,7 @@ ENV HWID RANDOM
|
||||||
ENV LOGLEVEL INFO
|
ENV LOGLEVEL INFO
|
||||||
ENV LOGFILE STDOUT
|
ENV LOGFILE STDOUT
|
||||||
ENV LOGSIZE ""
|
ENV LOGSIZE ""
|
||||||
ENV TYPE MINIMAL
|
|
||||||
|
|
||||||
COPY ./py-kms /home/py-kms
|
|
||||||
COPY docker/docker-py3-kms-minimal/requirements.txt /home/py-kms/requirements.txt
|
COPY docker/docker-py3-kms-minimal/requirements.txt /home/py-kms/requirements.txt
|
||||||
RUN apk add --no-cache --update \
|
RUN apk add --no-cache --update \
|
||||||
bash \
|
bash \
|
||||||
|
@ -30,6 +28,7 @@ bash \
|
||||||
# Fix undefined timezone, in case the user did not mount the /etc/localtime
|
# Fix undefined timezone, in case the user did not mount the /etc/localtime
|
||||||
&& ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
&& ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
||||||
|
|
||||||
|
COPY ./py-kms /home/py-kms
|
||||||
COPY docker/entrypoint.py /usr/bin/entrypoint.py
|
COPY docker/entrypoint.py /usr/bin/entrypoint.py
|
||||||
COPY docker/start.py /usr/bin/start.py
|
COPY docker/start.py /usr/bin/start.py
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ ENV LOGFILE STDOUT
|
||||||
ENV LOGSIZE ""
|
ENV LOGSIZE ""
|
||||||
ENV TZ America/Chicago
|
ENV TZ America/Chicago
|
||||||
|
|
||||||
COPY py-kms /home/py-kms/
|
|
||||||
COPY docker/docker-py3-kms/requirements.txt /home/py-kms/
|
COPY docker/docker-py3-kms/requirements.txt /home/py-kms/
|
||||||
RUN apk add --no-cache --update \
|
RUN apk add --no-cache --update \
|
||||||
bash \
|
bash \
|
||||||
|
@ -33,14 +32,17 @@ RUN apk add --no-cache --update \
|
||||||
# Fix undefined timezone, in case the user did not mount the /etc/localtime
|
# Fix undefined timezone, in case the user did not mount the /etc/localtime
|
||||||
&& ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
&& ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
||||||
|
|
||||||
|
COPY py-kms /home/py-kms/
|
||||||
COPY docker/entrypoint.py /usr/bin/entrypoint.py
|
COPY docker/entrypoint.py /usr/bin/entrypoint.py
|
||||||
COPY docker/start.py /usr/bin/start.py
|
COPY docker/start.py /usr/bin/start.py
|
||||||
|
COPY LICENSE /LICENSE
|
||||||
|
|
||||||
RUN chmod 755 /usr/bin/entrypoint.py
|
RUN chmod 755 /usr/bin/entrypoint.py
|
||||||
|
|
||||||
WORKDIR /home/py-kms
|
WORKDIR /home/py-kms
|
||||||
|
|
||||||
EXPOSE ${PORT}/tcp
|
EXPOSE ${PORT}/tcp
|
||||||
|
EXPOSE 8080/tcp
|
||||||
|
|
||||||
HEALTHCHECK --interval=5m --timeout=3s --start-period=10s --retries=4 CMD echo | nc -z ${IP%% *} ${PORT} || exit 1
|
HEALTHCHECK --interval=5m --timeout=3s --start-period=10s --retries=4 CMD echo | nc -z ${IP%% *} ${PORT} || exit 1
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,11 @@ log_file = os.environ.get('LOGFILE', 'STDOUT')
|
||||||
listen_ip = os.environ.get('IP', '::').split()
|
listen_ip = os.environ.get('IP', '::').split()
|
||||||
listen_port = os.environ.get('PORT', '1688')
|
listen_port = os.environ.get('PORT', '1688')
|
||||||
|
|
||||||
|
|
||||||
def start_kms():
|
def start_kms():
|
||||||
|
# Make sure the full path to the db exists
|
||||||
|
if not os.path.exists(os.path.dirname(dbPath)):
|
||||||
|
os.makedirs(os.path.dirname(dbPath), exist_ok=True)
|
||||||
|
|
||||||
# Build the command to execute
|
# Build the command to execute
|
||||||
command = [PYTHON3, '-u', 'pykms_Server.py', listen_ip[0], listen_port]
|
command = [PYTHON3, '-u', 'pykms_Server.py', listen_ip[0], listen_port]
|
||||||
for (arg, env) in argumentVariableMapping.items():
|
for (arg, env) in argumentVariableMapping.items():
|
||||||
|
@ -41,10 +44,22 @@ def start_kms():
|
||||||
for i in range(1, len(listen_ip)):
|
for i in range(1, len(listen_ip)):
|
||||||
command.append("-n")
|
command.append("-n")
|
||||||
command.append(listen_ip[i] + "," + listen_port)
|
command.append(listen_ip[i] + "," + listen_port)
|
||||||
|
command.append('-s')
|
||||||
|
command.append(dbPath)
|
||||||
|
|
||||||
loggersrv.debug("server_cmd: %s" % (" ".join(str(x) for x in command).strip()))
|
loggersrv.debug("server_cmd: %s" % (" ".join(str(x) for x in command).strip()))
|
||||||
pykms_process = subprocess.Popen(command)
|
pykms_process = subprocess.Popen(command)
|
||||||
|
|
||||||
|
try:
|
||||||
|
time.sleep(2) # Wait for the server to start up
|
||||||
|
pykms_webui_env = os.environ.copy()
|
||||||
|
pykms_webui_env['PYKMS_SQLITE_DB_PATH'] = dbPath
|
||||||
|
pykms_webui_env['PORT'] = '8080'
|
||||||
|
pykms_webui_env['PYKMS_LICENSE_PATH'] = '/LICENSE'
|
||||||
|
pykms_webui_process = subprocess.Popen(['gunicorn', '--log-level', os.environ.get('LOGLEVEL'), 'pykms_WebUI:app'], env=pykms_webui_env)
|
||||||
|
except Exception as e:
|
||||||
|
loggersrv.error("Failed to start webui: %s" % e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pykms_process.wait()
|
pykms_process.wait()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -52,7 +67,7 @@ def start_kms():
|
||||||
pass
|
pass
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
pykms_webui_process.terminate()
|
||||||
pykms_process.terminate()
|
pykms_process.terminate()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ def root():
|
||||||
@app.route('/license')
|
@app.route('/license')
|
||||||
def license():
|
def license():
|
||||||
_increase_serve_count()
|
_increase_serve_count()
|
||||||
with open('../LICENSE', 'r') as f:
|
with open(os.environ.get('PYKMS_LICENSE_PATH', '../LICENSE'), 'r') as f:
|
||||||
return render_template(
|
return render_template(
|
||||||
'license.html',
|
'license.html',
|
||||||
path='/license/',
|
path='/license/',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue