Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Pyronear API
API_URL=https://api.pyronear.org

# Camera credentials (shared across all cameras unless overridden per-camera in credentials.json)
CAM_USER=my_dummy_login
CAM_PWD=my_dummy_pwd

# MediaMTX server IP (used by pyro-camera-api to build SRT output URLs)
MEDIAMTX_SERVER_IP=1.2.3.4

# Docker image tag for both services (defaults to "latest" if unset)
# Set to a specific version for pinned deployments, e.g. PYRO_ENGINE_VERSION=1.2.0
PYRO_ENGINE_VERSION=latest
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,18 @@ pip install -e pyro-engine/.

### Environment variables

Deployments usually rely on a `.env` file with information such as:
Deployments usually rely on a `.env` file. A `.env.example` is provided at the root of the repository as a reference:

```text
API_URL=https://api.pyronear.org
CAM_USER=my_dummy_login
CAM_PWD=my_dummy_pwd
MEDIAMTX_SERVER_IP=1.2.3.4
PYRO_ENGINE_VERSION=latest
```

`PYRO_ENGINE_VERSION` controls which Docker image tag is pulled for both services (defaults to `latest` if unset).

### Data directory

A `./data` directory is expected with at least:
Expand Down
22 changes: 19 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
pyro-camera-api:
build:
context: ./pyro_camera_api
image: pyronear/pyro-camera-api:latest
image: pyronear/pyro-camera-api:${PYRO_ENGINE_VERSION:-latest}
container_name: pyro-camera-api
environment:
CAM_USER: ${CAM_USER}
Expand All @@ -12,6 +12,12 @@ services:
- ./data:/usr/src/app/data
restart: always
network_mode: host
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8081/health || exit 1"]
interval: 30s
retries: 3
start_period: 20s
timeout: 5s
logging:
driver: json-file
options:
Expand All @@ -22,17 +28,27 @@ services:
engine:
build:
context: ./engine
image: pyronear/pyro-engine:latest
image: pyronear/pyro-engine:${PYRO_ENGINE_VERSION:-latest}
container_name: engine
environment:
API_URL: ${API_URL}
CAM_USER: ${CAM_USER}
CAM_PWD: ${CAM_PWD}
volumes:
- ./data:/usr/src/app/data
command: python run.py
command: >
sh -c '
truncate -s 0 engine.log &&
python run.py 2>&1 | tee -a engine.log
'
restart: always
network_mode: host
healthcheck:
test: ["CMD-SHELL", "grep -q 'confidence\\|Nighttime detected' engine.log || exit 1"]
interval: 30s
retries: 3
start_period: 20s
timeout: 5s
logging:
driver: json-file
options:
Expand Down
1 change: 1 addition & 0 deletions pyro_camera_api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV PYTHONPATH=/usr/src/app

RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
git \
ffmpeg \
libsm6 \
Expand Down
3 changes: 0 additions & 3 deletions pyroengine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ def _process_alerts(self) -> None:
except ValueError:
logger.error(f"Camera '{cam_id}' - non-JSON response body: {response.text}")
raise
except KeyError:
logger.error(f"Camera '{cam_id}' - unexpected API response: {response.text}")
raise

# Clear
self._alerts.popleft()
Expand Down
Loading