Skip to content

Commit

Permalink
auto reload is working
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Aug 24, 2023
1 parent 53012e8 commit ba78f7a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 35 deletions.
16 changes: 3 additions & 13 deletions services/ansible_openvpn/docker/dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
# syntax=docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder

WORKDIR /app
WORKDIR /dashboard

RUN apk add nano openssh-server

COPY requirements.txt /app
COPY . /dashboard

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
4 changes: 4 additions & 0 deletions services/ansible_openvpn/docker/dashboard/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Derived from this work
https://github.com/docker/awesome-compose/tree/c2f8036fd353dae457eba7b9b436bf3a1c85d937/flask

To test locally

docker build -t flasktest .
docker run --name flasktest -p 8000:8000 flasktest
24 changes: 2 additions & 22 deletions services/ansible_openvpn/docker/dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,7 @@
# 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>"""

from scripts import serve

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)
serve.main()
Empty file.
24 changes: 24 additions & 0 deletions services/ansible_openvpn/docker/dashboard/scripts/serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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>"""


def main():
from waitress import serve
import hupper
reloader = hupper.start_reloader('scripts.serve.main')
reloader.watch_files(['app_git_hash.txt'])
serve(app, host="0.0.0.0", port=8000)

0 comments on commit ba78f7a

Please sign in to comment.