Skip to content

Commit

Permalink
start working on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Aug 24, 2023
1 parent 03a4b43 commit 53012e8
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 1 deletion.
31 changes: 31 additions & 0 deletions services/ansible_openvpn/docker/dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# syntax=docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder

WORKDIR /app

RUN apk add nano openssh-server

COPY requirements.txt /app
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install -r requirements.txt

COPY . /app

ENTRYPOINT ["python3"]
CMD ["app.py"]

FROM builder as dev-envs

RUN <<EOF
apk update
apk add git
EOF

RUN <<EOF
addgroup -S docker
adduser -S --shell /bin/bash --ingroup docker vscode
EOF
# install Docker tools (cli, buildx, compose)
COPY --from=gloursdocker/docker / /

USER vscode
3 changes: 3 additions & 0 deletions services/ansible_openvpn/docker/dashboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Derived from this work
https://github.com/docker/awesome-compose/tree/c2f8036fd353dae457eba7b9b436bf3a1c85d937/flask

53 changes: 53 additions & 0 deletions services/ansible_openvpn/docker/dashboard/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# BSD 3-Clause License
#
# Copyright (c) 2023, University Gustave Eiffel
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from flask import Flask
app = Flask(__name__)


@app.route('/')
def home():
return """
<!doctype html>
<html>
<head>
<title>NoiseSensor dashboard default page</title>
</head>
<body>
<p>Please run the Ansible playbook named deploy_elastic_web_dashboard.yml</p>
</body>
</html>"""


if __name__ == "__main__":
from waitress import serve
import hupper
reloader = hupper.start_reloader('dashboard.scripts.serve.main')
reloader.watch_files(['app_git_hash.txt'])
serve(app, host="0.0.0.0", port=8000)
1 change: 1 addition & 0 deletions services/ansible_openvpn/docker/dashboard/app_git_hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0000000000000000000000000
3 changes: 3 additions & 0 deletions services/ansible_openvpn/docker/dashboard/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flask
waitress
hupper
7 changes: 6 additions & 1 deletion services/ansible_openvpn/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ services:
interval: 10s
timeout: 10s
retries: 120

dashboard:
build:
context: dashboard
target: builder
ports:
- '8000:8000'
volumes:
semaphore-mysql:
semaphore-data: # storage of raw sensor data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Execute python script to parse data files and push it to the elastic search instance
hosts: webfrontend
connection: local
vars:
api_key: "{{ lookup('ansible.builtin.env', 'ELASTIC_SEARCH_API_KEY') }}"
api_key_id: "{{ lookup('ansible.builtin.env', 'ELASTIC_SEARCH_API_KEY_ID') }}"

0 comments on commit 53012e8

Please sign in to comment.