Skip to content

Commit cbb31fa

Browse files
authored
Merge pull request #3 from HusseinKabbout/master
Update docker documentation, remove pg_service file and also added probe tests for kubernetes
2 parents 497e0bd + 90b7b68 commit cbb31fa

File tree

4 files changed

+44
-21
lines changed

4 files changed

+44
-21
lines changed

Dockerfile

-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@ RUN apk add --no-cache --update postgresql-dev gcc python3-dev musl-dev git
99

1010
ADD . /srv/qwc_service
1111
RUN pip3 install --no-cache-dir -r /srv/qwc_service/requirements.txt
12-
13-
ADD pg_service.conf /var/www/.pg_service.conf
14-
ARG DB_USER=qwc_service
15-
ARG DB_PASSWORD=qwc_service
16-
RUN sed -i -e "s/^user=qwc_service/user=$DB_USER/" -e "s/^password=qwc_service/password=$DB_PASSWORD/" /var/www/.pg_service.conf

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ API documentation:
3838

3939
http://localhost:5018/api/
4040

41+
42+
Docker usage
43+
------------
44+
45+
To run this docker image you will need a configuration database. For testing purposes you can use the demo DB.
46+
47+
The following steps explain how to download the demo DB docker image and how to run the `qwc-permalink-service` with `docker-compose`.
48+
49+
**Step 1: Clone qwc-docker**
50+
51+
git clone https://github.com/qwc-services/qwc-docker
52+
cd qwc-docker
53+
54+
**Step 2: Create docker-compose.yml file**
55+
56+
cp docker-compose-example.yml docker-compose.yml
57+
58+
**Step 3: Start docker containers**
59+
60+
docker-compose up qwc-permalink-service
61+
62+
For more information please visit: https://github.com/qwc-services/qwc-docker
63+
4164
Development
4265
-----------
4366

pg_service.conf

-15
This file was deleted.

server.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from flask import Flask, request, jsonify
1+
from flask import Flask, request, jsonify, make_response
22
from flask_restplus import Api, Resource, reqparse
33
from flask_jwt_extended import jwt_optional, get_jwt_identity
44
import datetime
@@ -172,6 +172,26 @@ def post(self):
172172

173173
return jsonify({"success": True})
174174

175+
176+
""" readyness probe endpoint """
177+
@app.route("/ready", methods=['GET'])
178+
def ready():
179+
return jsonify({"status": "OK"})
180+
181+
182+
""" liveness probe endpoint """
183+
@app.route("/healthz", methods=['GET'])
184+
def healthz():
185+
try:
186+
configdb.connect()
187+
except Exception as e:
188+
return make_response(jsonify(
189+
{"status": "FAIL", "cause":
190+
str(e)}), 500)
191+
192+
return jsonify({"status": "OK"})
193+
194+
175195
if __name__ == "__main__":
176196
print("Starting Permalink service...")
177197
from flask_cors import CORS

0 commit comments

Comments
 (0)