diff --git a/Dockerfile b/Dockerfile index d89bb82..9f740fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,9 @@ EXPOSE 8000 # Define environment variable ENV NAME=World +ENV VERSION=dev # Run app.py when the container launches CMD ["fastapi", "run", "app.py"] -#harbor.freshbrewed.science/library/pybsposter:0.2.0 +#harbor.freshbrewed.science/library/pybsposter:0.2.1 diff --git a/app.py b/app.py index d95bdcf..32303c2 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ from typing import Union from fastapi import FastAPI, HTTPException from fastapi.responses import HTMLResponse +from fastapi.staticfiles import StaticFiles from datetime import datetime from atproto import Client, client_utils from pydantic import BaseModel @@ -11,6 +12,10 @@ app = FastAPI() + +# Mount the `static` directory to serve static files +app.mount("/static", StaticFiles(directory="static"), name="static") + class SocialPost(BaseModel): username: str password: str @@ -59,24 +64,71 @@ def read_root(): print(f"Error: {e}") uptime_seconds, current_time, logs = "N/A", "N/A", ["Error reading metrics or logs"] + # Get app version from environment variable + app_version = os.environ.get("VERSION", "unknown") + return f""" -
-         ______        ______      ______              _               
-        | ___ \       | ___ \     | ___ \            | |              
-        | |_/ / _   _ | |_/ / ___ | |_/ /  ___   ___ | |_   ___  _ __ 
-        |  __/ | | | || ___ \/ __||  __/  / _ \ / __|| __| / _ \| '__|
-        | |    | |_| || |_/ /\__ \| |    | (_) |\__ \| |_ |  __/| |   
-        \_|     \__, |\____/ |___/\_|     \___/ |___/ \__| \___||_|   
-                __/ |                                                
-                |___/                                                 
-        
-
-
-

Container Metrics

-

Uptime: {uptimeoutput}

-

Last Updated: {current_time}

-

Recent Logs:

- + + + + + + PyBsPoster + + + + +
+ +

Welcome to PyBSPoster

+

The application is running smoothly.

+

Documentation for this instance can be found:

+
Swagger (OpenAPI)
Redocs
+
Version: {app_version}


+
Uptime: {uptimeoutput}


+
Last Updated: {current_time}
+
+ + """ @@ -112,6 +164,18 @@ async def preview_social(post: SocialPost): @app.post("/post") async def post_social(post: SocialPost): + """ + Post to BlueSky. + + Args: + post (SocialPost): Contains the text, optional link + username and password for your BlueSky account. + + NOTE: baseURL is not used for BlueSky, but is included for consistency. + + Returns: + Response from Bluesky or status message. + """ # Debug # print(f"Received username: {post.username}", flush=True) # print(f"Received password: {post.password}", flush=True) @@ -162,8 +226,10 @@ async def post_to_mastodon(post: SocialPost): post (SocialPost): Contains the text, optional link, and the Mastodon instance URL (baseURL). the password is the API key for Mastodon. + NOTE: The username is not used for Mastodon, but is included for consistency. + Returns: - dict: Response from Mastodon or status message. + Response from Mastodon or status message. """ # Ensure the baseURL is provided for Mastodon posts if not post.baseURL: diff --git a/charts/pybsposter/Chart.yaml b/charts/pybsposter/Chart.yaml index 7bc87d9..f74c0b2 100644 --- a/charts/pybsposter/Chart.yaml +++ b/charts/pybsposter/Chart.yaml @@ -2,6 +2,6 @@ apiVersion: v2 name: pybsposter description: A Helm chart for deploying the pybsposter application type: application -version: 0.1.3 -appVersion: "2.1" +version: 0.1.4 +appVersion: "2.2" diff --git a/charts/pybsposter/templates/deployment.yaml b/charts/pybsposter/templates/deployment.yaml index 4912792..f86a1a3 100644 --- a/charts/pybsposter/templates/deployment.yaml +++ b/charts/pybsposter/templates/deployment.yaml @@ -20,6 +20,9 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - containerPort: {{ .Values.service.targetPort }} + env: + - name: VERSION + value: "{{ .Values.image.tag }}" resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..0d69c18 Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 0000000..6218135 Binary files /dev/null and b/static/logo.png differ diff --git a/static/logo3.png b/static/logo3.png new file mode 100644 index 0000000..1a80647 Binary files /dev/null and b/static/logo3.png differ