From 097b5818f8e42cb710b6250a5874516e5301747f Mon Sep 17 00:00:00 2001 From: Dorian Koch <doriank@fsmpi.rwth-aachen.de> Date: Thu, 5 Dec 2024 12:21:55 +0100 Subject: [PATCH] Add webserver --- Dockerfile | 5 +++-- docker-compose.yml | 23 ++++++++++++++++++++++- run_visualize_webserver.sh | 9 +++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 run_visualize_webserver.sh diff --git a/Dockerfile b/Dockerfile index 596216a..dad6534 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,9 @@ RUN apt-get update \ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY wait-for-it.sh . -RUN chmod +x wait-for-it.sh +COPY *.html . +COPY *.sh . +RUN chmod +x *.sh COPY *.py . CMD ["python", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml index 858493d..990be54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,4 @@ services: - monitor: build: . init: true @@ -13,6 +12,28 @@ services: - postgres command: ["./wait-for-it.sh", "postgres:5432", "--", "python", "main.py"] + visualize: + build: . + init: true + restart: unless-stopped + environment: + - DB_HOST=postgres + - DB_NAME=response_times + - DB_USER=myuser + - DB_PASSWORD=mypassword + depends_on: + - postgres + - monitor + ports: + - 12923:12923 + command: + [ + "./wait-for-it.sh", + "postgres:5432", + "--", + "./run_visualize_webserver.sh", + ] + postgres: image: postgres:13 restart: unless-stopped diff --git a/run_visualize_webserver.sh b/run_visualize_webserver.sh new file mode 100644 index 0000000..1a8acba --- /dev/null +++ b/run_visualize_webserver.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +python export.py > exported.csv +mkdir -p /var/www/html +mv exported.csv /var/www/html +cp visualize.html /var/www/html + +cd /var/www/html +python3 -m http.server 12923 \ No newline at end of file -- GitLab