mirror of
https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
synced 2024-11-22 14:28:48 +00:00
include version and commit hash in status endpoint
This commit is contained in:
parent
fdaedacfa5
commit
af6b17319d
@ -8,6 +8,8 @@ build:
|
|||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH
|
- if: $CI_COMMIT_BRANCH
|
||||||
tags: [ docker ]
|
tags: [ docker ]
|
||||||
|
before_script:
|
||||||
|
- echo "COMMIT=`git rev-parse HEAD`" >> version.env
|
||||||
script:
|
script:
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
- docker build . --tag ${CI_REGISTRY}/${CI_PROJECT_PATH}/${CI_BUILD_REF_NAME}:${CI_BUILD_REF}
|
- docker build . --tag ${CI_REGISTRY}/${CI_PROJECT_PATH}/${CI_BUILD_REF_NAME}:${CI_BUILD_REF}
|
||||||
|
@ -10,7 +10,7 @@ Just a simple *hello world* endpoint.
|
|||||||
|
|
||||||
### `GET /status`
|
### `GET /status`
|
||||||
|
|
||||||
Status endpoint, used for *healthcheck*.
|
Status endpoint, used for *healthcheck*. Shows also current version and commit hash.
|
||||||
|
|
||||||
### `GET /-/origins`
|
### `GET /-/origins`
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@ import dataset
|
|||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
from Crypto.PublicKey.RSA import RsaKey
|
from Crypto.PublicKey.RSA import RsaKey
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
dotenv_values('version.env')
|
||||||
|
|
||||||
|
VERSION, COMMIT, DEBUG = getenv('VERSION', 'unknown'), getenv('COMMIT', 'unknown'), bool(getenv('DEBUG', False))
|
||||||
|
|
||||||
|
|
||||||
def load_file(filename) -> bytes:
|
def load_file(filename) -> bytes:
|
||||||
with open(filename, 'rb') as file:
|
with open(filename, 'rb') as file:
|
||||||
@ -60,7 +65,7 @@ async def index():
|
|||||||
|
|
||||||
@app.get('/status')
|
@app.get('/status')
|
||||||
async def status(request: Request):
|
async def status(request: Request):
|
||||||
return JSONResponse({'status': 'up'})
|
return JSONResponse({'status': 'up', 'version': VERSION, 'commit': COMMIT, 'debug': DEBUG})
|
||||||
|
|
||||||
|
|
||||||
@app.get('/-/origins')
|
@app.get('/-/origins')
|
||||||
|
@ -5,3 +5,4 @@ pycryptodome==3.16.0
|
|||||||
python-dateutil==2.8.2
|
python-dateutil==2.8.2
|
||||||
dataset==1.5.2
|
dataset==1.5.2
|
||||||
markdown==3.4.1
|
markdown==3.4.1
|
||||||
|
python-dotenv==0.21.0
|
||||||
|
1
version.env
Normal file
1
version.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
VERSION=0.5
|
Loading…
Reference in New Issue
Block a user