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..5d9e184 100644 --- a/application/README.md +++ b/application/README.md @@ -1,5 +1,7 @@ # Sample kiosk application +## Local version + Build the container image. ```sh @@ -9,13 +11,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. @@ -30,3 +32,7 @@ Publish it to the registry. podman tag localhost/kiosk-app:latest quay.io/nmasse_itix/kiosk-app:latest podman push quay.io/nmasse_itix/kiosk-app:latest ``` + +## Online version + +The online version is deployed using [Netlify](https://app.netlify.com/) at [redhat-kiosk-app.netlify.app](https://redhat-kiosk-app.netlify.app/). 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 }}
-
- - diff --git a/rpms/SOURCES/microshift-main-manifest.yaml b/rpms/SOURCES/microshift-main-manifest.yaml index 31998f3..51708e0 100644 --- a/rpms/SOURCES/microshift-main-manifest.yaml +++ b/rpms/SOURCES/microshift-main-manifest.yaml @@ -18,6 +18,7 @@ data: global log stdout format raw local0 maxconn 4000 + ssl-server-verify none defaults mode http @@ -36,20 +37,25 @@ data: frontend webserver bind 0.0.0.0:8080 + + # The following configuration monitors availability of the main backend + # and if there is no more available servers in the main backend (online), + # it redirects to the backup backend (local). acl main_service_failed nbsrv(appserver_main) le 0 use_backend appserver_backup if main_service_failed default_backend appserver_main backend appserver_main - http-request set-header Host ipinfo.io + http-request set-header Host redhat-kiosk-app.netlify.app balance roundrobin - # 34.117.186.192 is one of the IP Addresses serving the website "ipinfo.io" - server svc-main1 34.117.186.192:80 check + # IP Addresses of the Netlify's APEX Load Balancer (apex-loadbalancer.netlify.com) + server svc-main1 75.2.60.5:443 check ssl sni str(redhat-kiosk-app.netlify.app) + server svc-main2 99.83.231.61:443 check ssl sni str(redhat-kiosk-app.netlify.app) backend appserver_backup http-request set-header Host kiosk-app.kiosk-app.svc.cluster.local balance roundrobin - server svc-backup1 kiosk-app:5000 check + server svc-backup1 kiosk-app:8080 check --- apiVersion: apps/v1 kind: Deployment @@ -117,7 +123,7 @@ spec: - name: kiosk-app image: quay.io/nmasse_itix/kiosk-app:latest ports: - - containerPort: 5000 + - containerPort: 8080 --- apiVersion: v1 kind: Service @@ -127,7 +133,7 @@ metadata: spec: type: ClusterIP ports: - - port: 5000 - targetPort: 5000 + - port: 8080 + targetPort: 8080 selector: app: kiosk-app