Add event processing container

This commit is contained in:
30hours 2024-02-09 00:41:51 +00:00
parent 447af3fd70
commit 22e51a94e7
19 changed files with 55 additions and 7 deletions

View file

@ -1,7 +1,7 @@
FROM python:3.9-slim FROM python:3.9-slim
WORKDIR /app WORKDIR /app
COPY src /app COPY api /app
# install any needed packages specified in requirements.txt # install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -5,15 +5,29 @@ networks:
services: services:
3lips: api:
restart: always restart: always
build: . build:
image: 3lips context: .
dockerfile: ./api/Dockerfile
image: 3lips-api
ports: ports:
- 49156:5000 - 49156:5000
networks: networks:
- 3lips - 3lips
container_name: 3lips container_name: 3lips-api
event:
restart: always
build:
context: ./event
dockerfile: Dockerfile
image: 3lips-event
networks:
- 3lips
volumes:
- ./db:/app/db
container_name: 3lips-event
cesium-apache: cesium-apache:
restart: always restart: always
@ -23,5 +37,6 @@ services:
image: cesium-apache image: cesium-apache
networks: networks:
- 3lips - 3lips
volumes:
- ./db:/app/db
container_name: 3lips-cesium container_name: 3lips-cesium

14
event/Dockerfile Normal file
View file

@ -0,0 +1,14 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Run the command when the container launches
CMD ["python", "./event.py"]

18
event/event.py Normal file
View file

@ -0,0 +1,18 @@
import asyncio
from datetime import datetime
print('testtttttt', flush=True)
async def event():
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print("Event triggered at: " + timestamp, flush=True)
# Create and run the event loop
async def main():
# Run the event loop
while True:
await event()
await asyncio.sleep(1)
if __name__ == "__main__":
asyncio.run(main())

1
event/requirements.txt Normal file
View file

@ -0,0 +1 @@
numpy==1.26.4