Added some basic stuff
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9d020e9895
commit
e11e6ffc3b
26
Dockerfile
26
Dockerfile
@ -1,28 +1,12 @@
|
||||
# Use the official lightweight Python image.
|
||||
# https://hub.docker.com/_/python
|
||||
FROM python:3.8-slim
|
||||
|
||||
# Copy local code to the container image.
|
||||
ENV APP_HOME /app
|
||||
ENV PIP_NO_CACHE_DIR=true
|
||||
ADD extractor_service requirements.txt /extractor_service/
|
||||
WORKDIR /extractor_service/
|
||||
|
||||
# Set timezone
|
||||
ENV PIP_NO_CACHE_DIR=true
|
||||
ENV TZ Europe/Budapest
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
WORKDIR $APP_HOME
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
ARG RELEASE_ID
|
||||
ENV RELEASE_ID ${RELEASE_ID:-""}
|
||||
|
||||
#Copy requirements to install
|
||||
COPY requirements.txt ./
|
||||
|
||||
# Install production dependencies.
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY ./src ./src
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:8080", "--workers", "1", "--threads", "8", "app:app"]
|
||||
ENTRYPOINT ["python3","main.py"]
|
||||
|
33
extractor_service/main.py
Normal file
33
extractor_service/main.py
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import pika
|
||||
|
||||
|
||||
def message_callback(ch, method, properties, body):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(filename="", format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s",
|
||||
level=logging.DEBUG if '--debug' in sys.argv else logging.INFO)
|
||||
|
||||
connection = pika.BlockingConnection(pika.connection.URLParameters(os.environ['PIKA_URL']))
|
||||
channel = connection.channel()
|
||||
channel.exchange_declare(exchange='wave-extract', exchange_type='fanout')
|
||||
|
||||
queue_declare_result = channel.queue_declare(queue='', exclusive=True)
|
||||
queue_name = queue_declare_result.method.queue
|
||||
|
||||
channel.queue_bind(exchange='wave-extract', queue=queue_name)
|
||||
channel.basic_consume(queue=queue_name, on_message_callback=message_callback, auto_ack=True)
|
||||
|
||||
try:
|
||||
channel.start_consuming()
|
||||
except KeyboardInterrupt:
|
||||
channel.stop_consuming()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,2 +1,3 @@
|
||||
sentry_sdk
|
||||
gunicorn
|
||||
pika
|
||||
requests
|
Reference in New Issue
Block a user