Skip to content
Snippets Groups Projects
Commit b9964b47 authored by Cornelia Michlits's avatar Cornelia Michlits
Browse files

#104 add fda-units-service

parent 13e21da7
No related branches found
No related tags found
4 merge requests!81New stable release,!43Merge dev to master,!33Draft: merge dev to master,!32Add units-service to dev
......@@ -251,6 +251,26 @@ services:
logging:
driver: json-file
fda-units-service:
restart: on-failure
container_name: fda-units-service
hostname: fda-units-service
build: ./fda-units-service
image: fda-units-service
networks:
- fda-public
environment:
EUREKA_SERVER: http://fda-discovery-service:9090/eureka/
ports:
- "5010:5010"
volumes:
- /tmp:/tmp
depends_on:
fda-discovery-service:
condition: service_healthy
logging:
driver: json-file
fda-broker-service:
restart: on-failure
container_name: fda-broker-service
......
FROM python:3.8-slim
MAINTAINER Cornelia Michlits <cornelia.michlits@tuwien.ac.at>
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV PORT_APP=5010
ENV FLASK_ENV=production
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt > /dev/null
COPY ./us-yml ./
COPY ./*.py ./
COPY ./service_ready ./
RUN chmod +x ./service_ready
EXPOSE $PORT_APP
ENTRYPOINT [ "python", "./pywsgi.py" ]
CMD ["flask", "run"]
import os
from flask import Flask, flash, request, redirect, url_for, Response, abort, jsonify
import logging
import py_eureka_client.eureka_client as eureka_client
import json
from flasgger import Swagger
from flasgger.utils import swag_from
from flasgger import LazyString, LazyJSONEncoder
app = Flask(__name__)
app.config["SWAGGER"] = {"title": "FDA-Units-Service", "uiversion": 3}
swagger_config = {
"headers": [],
"specs": [
{
"title": "units",
"endpoint": "api-units",
"route": "/api-units.json"
}
],
"static_url_path": "/flasgger_static",
"swagger_ui": True,
"specs_route": "/swagger-ui/",
}
template = dict(
swaggerUiPrefix=LazyString(lambda: request.environ.get("HTTP_X_SCRIPT_NAME", ""))
)
app.json_encoder = LazyJSONEncoder
swagger = Swagger(app, config=swagger_config, template=template)
@app.route('/api/units/suggest', methods=["POST"], endpoint='units_suggest')
#@swag_from('/as-yml/suggest.yml')
def suggest():
return 200
rest_server_port = 5010
eureka_client.init(eureka_server=os.getenv('EUREKA_SERVER', 'http://localhost:9090/eureka/'),
app_name="fda-units-service",
instance_ip="fda-units-service",
instance_host="fda-units-service",
instance_port=rest_server_port)
if __name__ == '__main__':
http_server = WSGIServer(('', 5010), app)
http_server.serve_forever()
from gevent import monkey
monkey.patch_all()
import os
from gevent.pywsgi import WSGIServer
from app import app
http_server = WSGIServer(('0.0.0.0', int(os.environ['PORT_APP'])), app)
http_server.serve_forever()
flask==1.1.2
flasgger==0.9.5
py-eureka-client==0.9.1
docker==5.0.0
sqlalchemy==1.4.15
gevent==21.8.0
#!/usr/local/bin/python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1', 5000))
if result == 0:
print("Port is open")
exit(0)
else:
print("Port is not open")
exit(1)
sock.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment