From 373cc04670804696a3bdd4f9ef2a93c6388423c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Wed, 28 Feb 2024 11:07:07 +0100 Subject: [PATCH] use the same code for online and offline --- application/Dockerfile | 24 ++++--------------- application/README.md | 4 ++-- application/src/app.py | 20 ---------------- application/src/local/index.html | 36 ++++++++++++++++++++++++++++ application/src/online/index.html | 36 ++++++++++++++++++++++++++++ application/src/static/style.css | 18 -------------- application/src/templates/index.html | 29 ---------------------- 7 files changed, 78 insertions(+), 89 deletions(-) delete mode 100644 application/src/app.py create mode 100644 application/src/local/index.html create mode 100644 application/src/online/index.html delete mode 100644 application/src/static/style.css delete mode 100644 application/src/templates/index.html diff --git a/application/Dockerfile b/application/Dockerfile index 3c35911..f4a63f7 100644 --- a/application/Dockerfile +++ b/application/Dockerfile @@ -1,21 +1,5 @@ -# Use an official Python runtime as a parent image -FROM python:3.8-slim +# Use the Nginx unprivileged as a parent image +FROM docker.io/nginxinc/nginx-unprivileged:1.25-alpine -# Set the working directory in the container -WORKDIR /app - -# Copy the current directory contents into the container at /app -COPY src /app - -# Install any needed packages specified in requirements.txt -RUN pip install --trusted-host pypi.python.org Flask - -# Make port 80 available to the world outside this container -EXPOSE 5000 - -# Define environment variable -ENV NAME World - -# Run app.py when the container launches -CMD ["python", "app.py"] - \ No newline at end of file +# Copy the static content into the container at /usr/share/nginx/html/ +COPY src/local/index.html /usr/share/nginx/html/ diff --git a/application/README.md b/application/README.md index 9f46e7a..8378fc7 100644 --- a/application/README.md +++ b/application/README.md @@ -9,13 +9,13 @@ podman build -t localhost/kiosk-app:latest . Run the container image. ```sh -podman run -it --rm --name kiosk-app -p 5000:5000 localhost/kiosk-app:latest +podman run -it --rm --name kiosk-app -p 8080:8080 localhost/kiosk-app:latest ``` Test it. ```sh -curl -I http://localhost:5000/ +curl -I http://localhost:8080/ ``` Login to the registry. diff --git a/application/src/app.py b/application/src/app.py deleted file mode 100644 index f700f9c..0000000 --- a/application/src/app.py +++ /dev/null @@ -1,20 +0,0 @@ -import platform -from flask import Flask, render_template - -app = Flask(__name__, template_folder="/app/templates") - - -@app.route('/') -def system_info(): - system_info = { - 'System': platform.system(), - 'Node Name': platform.node(), - 'Release': platform.release(), - 'Version': platform.version(), - 'Machine': platform.machine(), - 'Processor': platform.processor() - } - return render_template('index.html', system_info=system_info) - -if __name__ == '__main__': - app.run(host="0.0.0.0", debug=True) \ No newline at end of file diff --git a/application/src/local/index.html b/application/src/local/index.html new file mode 100644 index 0000000..f5b6f67 --- /dev/null +++ b/application/src/local/index.html @@ -0,0 +1,36 @@ + + + + + + + + Kiosk application + + +
+

Kiosk application

+
+
+

You are viewing the local version.

+
+ + diff --git a/application/src/online/index.html b/application/src/online/index.html new file mode 100644 index 0000000..05ecb47 --- /dev/null +++ b/application/src/online/index.html @@ -0,0 +1,36 @@ + + + + + + + + Kiosk application + + +
+

Kiosk application

+
+
+

You are viewing the online version.

+
+ + diff --git a/application/src/static/style.css b/application/src/static/style.css deleted file mode 100644 index b2a609e..0000000 --- a/application/src/static/style.css +++ /dev/null @@ -1,18 +0,0 @@ -/* static/style.css */ -body { - font-family: Arial, sans-serif; - margin: 0; - padding: 0; - background-color: #f2f2f2; -} - -header { - background-color: #333; - color: white; - padding: 1em; - text-align: center; -} - -main { - margin: 2em; -} \ No newline at end of file diff --git a/application/src/templates/index.html b/application/src/templates/index.html deleted file mode 100644 index 89a0327..0000000 --- a/application/src/templates/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - System Information - - -
-

System Information

-
-
- - - - - - {% for key, value in system_info.items() %} - - - - - {% endfor %} -
AttributeValue
{{ key }}{{ value }}
-
- -