Compare commits

..

9 Commits

Author SHA1 Message Date
Krzysztof Płaczek
d22de35b7a test commit 2018-04-03 08:44:42 +02:00
Krzysztof Płaczek
c48882e605 Added requirements.json 2018-03-28 13:06:01 +02:00
Krzysztof Płaczek
5789934db9 Merge branch 'initial_fix' of http://pi.techtube.pl:3000/krzysiej/docker_flask into initial_fix
# Conflicts:
#	README.md
2018-03-26 08:52:43 +02:00
Krzysztof Płaczek
2255d759ec Updated README.md. 2018-03-26 08:50:58 +02:00
Krzysztof Płaczek
37a3395e7c Updated README.md. 2018-03-26 08:49:59 +02:00
Krzysztof Płaczek
d07cfe8089 Updated data presentation of image attributes and some minor css tweaks. 2018-03-23 08:34:49 +01:00
Krzysztof Płaczek
a26863e74f Displaying port mappings on container lists. Neater json formatting. 2018-03-22 10:46:55 +01:00
Krzysztof Płaczek
37e8224369 Instrukcja uruchomienia. 2018-03-21 11:37:35 +01:00
Krzysztof Płaczek
f17bd2af08 Ignored .idea directory. 2018-03-09 10:37:42 +01:00
9 changed files with 85 additions and 51 deletions

1
.gitignore vendored
View File

@@ -94,3 +94,4 @@ ENV/
# Rope project settings
.ropeproject
/.idea

View File

@@ -1,2 +1,15 @@
# docker_flask
## Run
pip install -r requirements.txt
set FLASK_APP=index.py
set FLASK_DEBUG=1
flask run -p 5001
or
pip install -r requirements.txt
python index.py

View File

@@ -5,6 +5,7 @@ import re
import unidecode
import datetime
import base64
import json
#
# from flask_wtf import FlaskForm
@@ -67,7 +68,8 @@ def images_all_action(client_name):
def image_action(client_name, image_id):
if client_name in clients:
image = clients[client_name].images.get(image_id)
return render_template('image.html', image=image, client_name=client_name)
return render_template('image.html', image=image, image_attributes=json.dumps(image.attrs, indent=4),
client_name=client_name)
else:
flash('Client name \'%s\' not found' % client_name)
return redirect(url_for('index'))
@@ -184,7 +186,12 @@ def containers_all_action(client_name):
def container_action(client_name, short_id=None):
if client_name in clients:
container = clients[client_name].containers.get(short_id)
return render_template('container.html', container=container, client_name=client_name)
# parsed = json.loads(container.attrs)
# print()
return render_template('container.html', container=container, client_name=client_name,
container_attributes=json.dumps(container.attrs, indent=4))
else:
flash('Client name \'%s\' not found' % client_name)
return redirect(url_for('index'))
@@ -380,5 +387,6 @@ def slugify(text):
app.secret_key = b'\xd7:o\\\xaayFe\x1ey\x08m9\xe4\xbc!\xee\x0e>\xd1Z\x99-\xbb'
# http://flask.pocoo.org/snippets/133/ @TODO
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5002, debug=True, threaded=True)
app.run(host="0.0.0.0", port=5001, debug=True, threaded=True)

17
requirements.txt Normal file
View File

@@ -0,0 +1,17 @@
certifi==2018.1.18
chardet==3.0.4
click==6.7
docker==3.1.4
docker-pycreds==0.2.2
Flask==0.12.2
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
pypiwin32==219
requests==2.18.4
six==1.11.0
Unidecode==1.0.22
urllib3==1.22
websocket-client==0.47.0
Werkzeug==0.14.1

View File

@@ -62,9 +62,9 @@ min-width: 140px;
table tbody tr:nth-child(2n+1) {
background-color: #f9f9f9; }
h1 { font-size: 2.75em; margin: 16px 32px 16px 32px;}
h2 { font-size: 2em; margin: 16px 32px 16px 16px;}
h3 { font-size: 1.5em; margin: 16px 32px 16px 32px;}
h1 { font-size: 2.75em; margin: 16px 32px 16px 0;}
h2 { font-size: 2em; margin: 16px 32px 16px 0;}
h3 { font-size: 1.5em; margin: 16px 32px 16px 0;}
a {color: dodgerblue; text-decoration: none; }
a:hover { text-decoration: underline; }
@@ -110,4 +110,18 @@ padding: 5px 15px;
.details__entrypoint { display: inline-block; width: 210px; }
.details__image { display: inline-block; }
.details__more-info {display: none; }
.details__more-info { margin: 5px 10px; }
.more-info__ports { }
.more-info__ports--line {
display: list-item;
list-style-position: inside;
margin: 8px 8px;
}
.container_attribute, .image_attribute {
}
.container_attribute-details, .image_attribute-details {
white-space: pre;
line-height: 1.1em;
}

View File

@@ -1,7 +1,8 @@
{% extends "layout.html" %}
{% block body %}
<h1><a href="/">Dashboard</a> &raquo; {{ client_name }} &raquo; <a href="/{{ client_name }}/containers">Containers</a> &raquo; {{ container.name }}</h1>
<h1><a href="/">Dashboard</a> &raquo; {{ client_name }} &raquo; <a href="/{{ client_name }}/containers">Containers</a>
&raquo; {{ container.name }}</h1>
<form action="{{ url_for('rename_container', client_name=client_name) }}" method="post">
<p><input type="text" name="name" size="60" value="{{ container.name }}"><!--
@@ -10,8 +11,7 @@
</form>
<h2>Details</h2>
<pre>
{{ container.attrs|pprint }}
</pre>
<div class="container_attribute">
<div class="container_attribute-details">{{ container_attributes }}</div>
</div>
{% endblock %}

View File

@@ -2,7 +2,7 @@
{% block body %}
<h1><a href="/">Dashboard</a> &raquo; {{ client_name }} &raquo; Containers</h1>
<h1><a href="/">Dashboard</a> &raquo; {{ client_name }} &raquo; <a href="/{{ client_name }}/containers">Containers</a></h1>
<a class="button--link" href="/{{ client_name }}/containers/all">All Containers</a>
@@ -28,26 +28,11 @@
container.attrs.Config.Labels['com.docker.compose.project'] }}</a></h2>
{% endif%}
<!--<table>-->
<!--<thead>-->
<!--<tr>-->
<!--<th>COMPOSE PROJECT</th>-->
<!--<th>CONTAINER ID</th>-->
<!--<th>NAME</th>-->
<!--<th>COMMAND</th>-->
<!--<th>CREATED</th>-->
<!--<th>STATUS</th>-->
<!--<th>PORTS</th>-->
<!--<th>IMAGE</th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody>-->
<div class="details">
<div>
<div class="details__status details__status--{{ container.status }}">{{ container.status }}</div>
<div class="details__name"><a class="button--link"
<div class="details__status details__status--{{ container.status }}">{{ container.status }}
</div><div
class="details__name"><a class="button--link"
href="/{{ client_name }}/containers/id/{{ container.short_id }}">{{
container.name
}}</a></div>
@@ -61,17 +46,15 @@
<div class="details__more-info">
<div class="more-info__ports">
{% for port in container.attrs['NetworkSettings']['Ports'] %}
{{ port }}
{% if container.attrs['NetworkSettings']['Ports'][port] is not none %}
{% if container.attrs['NetworkSettings']['Ports'][port] is not none and
container.attrs['NetworkSettings']['Ports'][port]|length > 0 %}
{% for port_exposed in container.attrs['NetworkSettings']['Ports'][port] %}
->{{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }}
<span class="more-info__ports--line">{{ port }} -> {{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }}</span>
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
</div>
</div>
@@ -80,17 +63,15 @@
</div>
<div class="details__controll">
<a class="button--link" href="/{{ client_name }}/containers/log/{{ container.short_id }}">log</a>
<a class="button--link" href="/{{ client_name }}/containers/export/{{ container.short_id }}">export</a>
{% if (container.status == 'exited') or (container.status == 'created') %}
<a class="button--link" href="/{{ client_name }}/containers/start/{{ container.short_id }}">start</a>
<a class="button--link" href="/{{ client_name }}/containers/remove/{{ container.short_id }}">remove</a>
{% endif %}
{% if container.status == 'running' %}
<a class="button--link" href="/{{ client_name }}/containers/stop/{{ container.short_id }}">stop</a>
<a class="button--link" href="/{{ client_name }}/containers/restart/{{ container.short_id }}">restart</a>
<a class="button--link" href="/{{ client_name }}/containers/top/{{ container.short_id }}">top</a>
<a class="button--link" href="/{{ client_name }}/containers/log/{{ container.short_id }}">log
</a><a class="button--link" href="/{{ client_name }}/containers/export/{{ container.short_id }}">export
</a>{% if (container.status == 'exited') or (container.status == 'created') %}<a class="button--link"
href="/{{ client_name }}/containers/start/{{ container.short_id }}">start
</a><a class="button--link" href="/{{ client_name }}/containers/remove/{{ container.short_id }}">remove</a>
{% endif %}{% if container.status == 'running' %}
<a class="button--link" href="/{{ client_name }}/containers/stop/{{ container.short_id }}">stop
</a><a class="button--link" href="/{{ client_name }}/containers/restart/{{ container.short_id }}">restart
</a><a class="button--link" href="/{{ client_name }}/containers/top/{{ container.short_id }}">top</a>
{% endif %}
</div>
</div>

View File

@@ -6,7 +6,7 @@
}} {% endif %}</h1>
<h2>Details</h2>
<pre>
{{ image.attrs | pprint }}
</pre>
<div class="image_attribute">
<div class="image_attribute-details">{{ image_attributes }}</div>
</div>
{% endblock %}

View File

@@ -2,7 +2,7 @@
{% block body %}
<h1><a href="/">Dashboard</a> &raquo; {{ client_name }} &raquo; Images</h1>
<h1><a href="/">Dashboard</a> &raquo; {{ client_name }} &raquo; <a href="/{{ client_name }}/images">Images</a></h1>
<a class="button--link" href="/{{ client_name }}/images/dangling">Dangling Images</a>