Skip to content
Snippets Groups Projects
Verified Commit b6e97fb0 authored by Martin Weise's avatar Martin Weise
Browse files

Fixed both Python services

parent ac5e307d
Branches
Tags
2 merge requests!163Relase 1.3.0,!159Large update
FROM python:3.9-alpine
MAINTAINER Martin Weise <martin.weise@tuwien.ac.at>
RUN apk update && apk --no-cache add build-base gcc python3-dev libpq-dev libffi-dev py3-pandas \
RUN apk update && apk --no-cache add build-base gcc python3-dev libpq-dev libffi-dev bash curl py3-pandas \
py3-sqlalchemy py3-requests py3-gevent py3-psycopg2
COPY ./requirements.txt ./requirements.txt
RUN pip install -r ./requirements.txt
COPY ./healthcheck.sh ./healthcheck.sh
RUN pip install -r requirements.txt > /dev/null
WORKDIR /app
......@@ -15,13 +17,10 @@ ENV PORT_APP=5000
ENV FLASK_ENV=production
ENV HOSTNAME=analyse-service
HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD ./service_ready
HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD ["bash", "/app/healthcheck.sh"]
COPY ./as-yml/ ./as-yml/
COPY ./*.py ./
COPY ./service_ready ./
RUN chmod +x ./service_ready
EXPOSE $PORT_APP
......
#!/bin/bash
HTTP_CODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" 'http://0.0.0.0:5000/metrics')
if test $HTTP_CODE -ne 200; then
exit 1
fi
\ No newline at end of file
#!/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
......@@ -2,7 +2,7 @@ FROM python:3.9-alpine
MAINTAINER Martin Weise <martin.weise@tuwien.ac.at>
RUN apk update && apk --no-cache add build-base gcc python3-dev libpq-dev libffi-dev mariadb-dev mariadb-connector-c \
mariadb-connector-c-dev py3-pandas py3-sqlalchemy py3-requests py3-gevent py3-psycopg2
mariadb-connector-c-dev curl bash py3-pandas py3-sqlalchemy py3-requests py3-gevent py3-psycopg2
COPY ./requirements.txt ./requirements.txt
RUN pip install -r ./requirements.txt
......@@ -14,7 +14,6 @@ ENV FLASK_RUN_HOST=0.0.0.0
ENV PORT_APP=5010
ENV FLASK_DEBUG=0
ENV HOSTNAME=semantics-service
ENV READY_FILE=/ready
ENV LOG_LEVEL=debug
ENV METADATA_DB=fda
ENV METADATA_USERNAME=root
......@@ -22,14 +21,12 @@ ENV METADATA_PASSWORD=dbrepo
ENV JWT_ISSUER=http://localhost:8080/realms/dbrepo
ENV JWT_PUBKEY=public-key
COPY requirements.txt requirements.txt
COPY ./requirements.txt ./requirements.txt
COPY ./healthcheck.sh ./healthcheck.sh
RUN pip install -r requirements.txt > /dev/null
COPY ./service_ready /usr/bin
RUN chmod +x /usr/bin/service_ready
HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD service_ready
HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD ["bash", "/app/healthcheck.sh"]
EXPOSE $PORT_APP
......
#!/bin/bash
HTTP_CODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" 'http://0.0.0.0:5010/metrics')
if test $HTTP_CODE -ne 200; then
exit 1
fi
\ No newline at end of file
......@@ -10,6 +10,4 @@ path = os.getenv('READY_FILE', './ready')
logging.basicConfig(format='%(asctime)s %(levelname)-6s %(message)s', level=logging.DEBUG)
http_server = WSGIServer(listener=(rest_server_host, rest_server_port), application=app, log=logging)
with open(path, 'w') as f:
logging.info(f'Service is ready, create file at {path}')
http_server.serve_forever()
#!/bin/bash
if [ -f "${READY_FILE}" ]; then
echo "service is ready and accepting connections"
exit 0
fi
exit 1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment