attempt to get git docker labels into version json file w/ burnettk

This commit is contained in:
jasquat 2023-04-07 15:32:28 -04:00
parent e2b8f17a7e
commit 3ff855350a
No known key found for this signature in database
4 changed files with 25 additions and 15 deletions

View File

@ -31,7 +31,7 @@ on:
push: push:
branches: branches:
- main - main
- feature/use_tasks_as_logs - feature/prometheus-metrics
jobs: jobs:
create_frontend_docker_image: create_frontend_docker_image:
@ -64,6 +64,12 @@ jobs:
type=ref,event=branch,suffix=-latest type=ref,event=branch,suffix=-latest
type=ref,event=branch,suffix=-${{ steps.date.outputs.date }} type=ref,event=branch,suffix=-${{ steps.date.outputs.date }}
- name: Write app verison info
run: |
touch app_version.json
echo '${{ steps.meta.outputs.labels }}' > app_version.json
id: app_version_info
run: echo "date=$(date -u +'%Y-%m-%d_%H-%M-%S')" >> "$GITHUB_OUTPUT"
- name: Build and push Frontend Docker image - name: Build and push Frontend Docker image
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.0.0
with: with:
@ -73,7 +79,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
- run: echo 'TAGS' >> "$GITHUB_STEP_SUMMARY" - run: echo 'TAGS' >> "$GITHUB_STEP_SUMMARY"
- run: echo 'for tag in ${{ steps.meta.outputs.tags }}; do echo "* $tag"; done' >> "$GITHUB_STEP_SUMMARY" - run: for tag in ${{ steps.meta.outputs.tags }}; do echo "* $tag"; done >> "$GITHUB_STEP_SUMMARY"
create_backend_docker_image: create_backend_docker_image:
runs-on: ubuntu-latest runs-on: ubuntu-latest

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ t
*~ *~
.dccache .dccache
*~ *~
app_version.json

View File

@ -1 +0,0 @@
{"version": "1.0.3"}

View File

@ -4,7 +4,7 @@ import faulthandler
import os import os
import sys import sys
from typing import Any from typing import Any
from prometheus_flask_exporter import PrometheusMetrics from prometheus_flask_exporter import ConnexionPrometheusMetrics
import connexion # type: ignore import connexion # type: ignore
import flask.app import flask.app
@ -128,17 +128,8 @@ def create_app() -> flask.app.Flask:
connexion_app = connexion.FlaskApp(__name__, server_args={"instance_path": os.environ.get("FLASK_INSTANCE_PATH")}) connexion_app = connexion.FlaskApp(__name__, server_args={"instance_path": os.environ.get("FLASK_INSTANCE_PATH")})
app = connexion_app.app app = connexion_app.app
app.config["CONNEXION_APP"] = connexion_app app.config["CONNEXION_APP"] = connexion_app
metrics = PrometheusMetrics(app)
info = metrics.info('dynamic_info', 'Something dynamic')
info.set(42.1)
# metrics.register_endpoint('/metricss')
app.config["PROMETHEUS_METRICS"] = metrics
app_version_data = {}
with open("app_version.json", 'r') as f:
app_version_data = json.load(f)
metrics.info('app_info', 'Application info', version='1.0.3')
app.config["SESSION_TYPE"] = "filesystem" app.config["SESSION_TYPE"] = "filesystem"
_setup_prometheus_metrics(app, connexion_app)
setup_config(app) setup_config(app)
db.init_app(app) db.init_app(app)
@ -194,6 +185,19 @@ def create_app() -> flask.app.Flask:
return app # type: ignore return app # type: ignore
def _setup_prometheus_metrics(app: flask.app.Flask, connexion_app: connexion.apps.flask_app.FlaskApp) -> None:
metrics = ConnexionPrometheusMetrics(connexion_app)
info = metrics.info('dynamic_info', 'Something dynamic')
info.set(42.1)
app.config["PROMETHEUS_METRICS"] = metrics
app_version_data = {}
if os.path.isfile("app_version.json"):
with open("app_version.json", 'r') as f:
app_version_data = json.load(f)
metrics.info('app_version_info', 'Application Version Info', **app_version_data)
def get_hacked_up_app_for_script() -> flask.app.Flask: def get_hacked_up_app_for_script() -> flask.app.Flask:
"""Get_hacked_up_app_for_script.""" """Get_hacked_up_app_for_script."""
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development" os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"