add nginx and change default file locations

This commit is contained in:
Blake Blackshear 2020-11-02 05:44:16 -06:00
parent eced06eea8
commit b7c09a9b38
8 changed files with 97 additions and 13 deletions

View File

@ -179,10 +179,10 @@ save_clips:
# will begin to expire and the resulting clip will be the last x seconds of the event.
max_seconds: 300
# Optional: Location to save event clips. (default: shown below)
clips_dir: /clips
clips_dir: /media/frigate/clips
# Optional: Location to save cache files for creating clips. (default: shown below)
# NOTE: To reduce wear on SSDs and SD cards, use a tmpfs volume.
cache_dir: /cache
cache_dir: /tmp/cache
# Optional: Global ffmpeg args
# "ffmpeg" + global_args + input_args + "-i" + input + output_args

View File

@ -15,7 +15,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update \
&& apt-get upgrade -y \
&& apt-get -qq install --no-install-recommends -y \
gnupg wget unzip tzdata \
gnupg wget unzip tzdata nginx \
&& apt-get -qq install --no-install-recommends -y \
python3-pip \
&& pip3 install -U /wheels/*.whl \
@ -27,6 +27,12 @@ RUN apt-get -qq update \
&& rm -rf /var/lib/apt/lists/* /wheels \
&& (apt-get autoremove -y; apt-get autoclean -y)
RUN pip3 install \
peewee \
voluptuous
COPY nginx/nginx.conf /etc/nginx/nginx.conf
# get model and labels
ARG MODEL_REFS=7064b94dd5b996189242320359dbab8b52c94a84
COPY labelmap.txt /labelmap.txt
@ -38,4 +44,7 @@ RUN mkdir /cache /clips
WORKDIR /opt/frigate/
ADD frigate frigate/
CMD ["python3", "-u", "-m", "frigate"]
COPY run.sh /run.sh
RUN chmod +x /run.sh
CMD ["/run.sh"]

View File

@ -32,9 +32,7 @@ RUN pip3 wheel --wheel-dir=/wheels \
paho-mqtt \
PyYAML \
matplotlib \
click \
peewee \
voluptuous
click
FROM scratch

View File

@ -42,9 +42,7 @@ RUN pip3 wheel --wheel-dir=/wheels \
paho-mqtt \
PyYAML \
matplotlib \
click \
peewee \
voluptuous
click
FROM scratch

View File

@ -36,7 +36,7 @@ class FrigateApp():
raw_config = f.read()
if config_file.endswith(".yml"):
config = yaml.load(raw_config)
config = yaml.safe_load(raw_config)
elif config_file.endswith(".json"):
config = json.loads(raw_config)

View File

@ -30,8 +30,8 @@ MQTT_SCHEMA = vol.Schema(
SAVE_CLIPS_SCHEMA = vol.Schema(
{
vol.Optional('max_seconds', default=300): int,
vol.Optional('clips_dir', default='/clips'): str,
vol.Optional('cache_dir', default='/cache'): str
vol.Optional('clips_dir', default='/media/frigate/clips'): str,
vol.Optional('cache_dir', default='/tmp/cache'): str
}
)

75
nginx/nginx.conf Normal file
View File

@ -0,0 +1,75 @@
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
client_max_body_size 50M;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
location /stream/ {
add_header 'Cache-Control' 'no-cache';
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Expose-Headers' 'Content-Length';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
image/jpeg jpg;
}
root /tmp;
}
location /frigate/ {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Expose-Headers' 'Content-Length';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
video/mp4 mp4;
image/jpeg jpg;
}
autoindex on;
root /media;
}
}
}

4
run.sh Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
service nginx start
python3 -u -m frigate