dev #1

Merged
sortion merged 26 commits from dev into main 2022-08-25 06:02:34 +02:00
9 changed files with 126 additions and 78 deletions
Showing only changes of commit c1af47eb26 - Show all commits

View File

@ -5,3 +5,6 @@ var
media
daemon/systemd
analyzer
vendor
node_modules
build

10
.env
View File

@ -3,10 +3,10 @@ CUDA_VISIBLE_DEVICES=""
# BirdNET-stream environment
DATABASE_USER="birdnet"
DATABASE_PASSWORD="secret"
DATABASE_PASSWORD="AShoo1N"
DATABASE_PORT="3306" # Change this if you have already a running MySQL server on the host
MYSQL_ROOT_PASSWORD="secret"
DATABASE_ROOT_PASSWORD="Ojiex5v"
RECORDS_FOLDER="./var/chunks"
CHARTS_FOLDER="./var/charts"
SERVER_NAME="birdnet.lan"
RECORDS_FOLDER=/media/DATA/birdnet/records/
CHARTS_FOLDER=/media/DATA/birdnet/charts/
SERVER_NAME="birdnet.local"

12
.env.example Normal file
View File

@ -0,0 +1,12 @@
# BirdNET-Analyzer environment
CUDA_VISIBLE_DEVICES=""
# BirdNET-stream environment
DATABASE_USER="birdnet"
DATABASE_PASSWORD="secret" # change this
DATABASE_PORT="3306" # change this if you have already a running MySQL server on the host
MYSQL_ROOT_PASSWORD="secret" # change this
RECORDS_FOLDER="/media/data/birdnet/records"
CHARTS_FOLDER="/media/data/birdnet/charts"
SERVER_NAME="birdnet.local"

View File

@ -10,67 +10,101 @@ services:
# environment:
# - CHUNK_FOLDER=${CHUNK_FOLDER:-/media/birdnet/records}
# volumes:
# - ./var/:/media/birdnet/records
# - ${RECORDS_FOLDER:-/media/birdnet/records}:${RECORS_FOLDER:-/media/birdnet/records}
# # Allow container to access to the hosts microphone
# devices:
# - /dev/snd
# - /dev/snd:/dev/snd
# analyzer:
# container_name: birdnet_analyzer
# build:
# context: ./analyzer/
# dockerfile: ./Dockerfile
db:
container_name: birdnet_database
image: mariadb:latest
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
ports:
- '3306:3306'
networks:
birdnet_network:
environment:
MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD:-secret}'
MYSQL_DATABASE: ${DATABASE:-birdnet}
MYSQL_USER: ${DATABASE_USER:-birdnet}
MYSQL_PASSWORD: ${DATABASE_PASSWORD:-secret}
volumes:
- ./docker/database/init:/docker-entrypoint-initdb.d
restart: unless-stopped
# db:
# container_name: birdnet_database
# image: mariadb:latest
# command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
# ports:
# - '3307:3306'
# networks:
# - birdnet_network
# environment:
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-secret}'
# MYSQL_DATABASE: ${DATABASE:-birdnet}
# MYSQL_USER: ${DATABASE_USER:-birdnet}
# MYSQL_PASSWORD: ${DATABASE_PASSWORD:-secret}
# volumes:
# - ./docker/database/init:/docker-entrypoint-initdb.d
# restart: unless-stopped
php-fpm:
container_name: birdnet_php-fpm
image: php:${PHP_VERSION:-8.1}-fpm
ports:
- ${PHP_FPM_PORT:-9000}:9000
networks:
birdnet_network:
restart: unless-stopped
volumes:
- birdnet_app:${PROJECT_ROOT:-/opt/birdnet}
symfony:
container_name: birdnet_symfony
hostname: birdnet.symfony
networks:
birdnet_network:
build:
context: .
dockerfile: ./docker/symfony/Dockerfile
environment:
- DATABASE_DEFAULT_URL=${DATABASE_DEFAULT_URL:-mysql://${DATABASE_USER:-birdnet}:${DATABASE_PASSWORD:-secret}@${DATABASE_HOST:-db}:3306/birdnet_default}
- DATABASE_OBSERVATION_URL=${DATABASE_OBSERVATION_URL:-mysql://${DATABASE_USER:-birdnet}:${DATABASE_PASSWORD:-secret}@${DATABASE_HOST:-db}:3306/birdnet_observation}
- RECORDS_FOLDER=${RECORDS_FOLDER:-/media/birdnet/records}
restart: unless-stopped
volumes:
networks:
- birdnet_network
- birdnet_app:${PROJECT_ROOT:-/opt/birdnet}
- birdnet_recordings:${RECORDS_FOLDER:-/media/birdnet/records}
depends_on:
- db
nginx:
container_name: birdnet_nginx
hostname: birdnet.nginx
build:
context: .
dockerfile: ./docker/nginx/Dockerfile
args:
- SERVER_NAME=${SERVER_NAME:-birnet.local}
- SYMFONY_PUBLIC=${SYMFONY_PUBLIC:-/opt/birdnet/www/public}
- CHARTS_FOLDER=${CHARTS_FOLDER:-/media/birdnet/charts}
- RECORDS_FOLDER=${RECORDS_FOLDER:-/media/birdnet/records}
- PHP_FPM_HOST=${PHP_FPM_HOST:-php-fpm}
- PHP_FPM_PORT=${PHP_FPM_PORT:-9000}
ports:
- '81:80'
- '444:443'
environment:
- PHP_FPM_PORT=${PHP_FPM_PORT:-9001}
- PHP_FPM_HOST=${PHP_FPM_HOST:-birdnet.php-fpm}
- '80:80'
- '443:443'
volumes:
- birdnet_app:${RECORDS_FOLDER-/opt/birdnet}
- birdnet_recordings:${RECORDS_FOLDER-/media/data/records}
networks:
- birdnet_network
birdnet_network:
ipv4_address: ${IP_ADDRESS:-172.25.0.101}
aliases:
- ${SERVER_NAME:-birdnet.local}
restart: unless-stopped
depends_on:
- symfony
- php-fpm
networks:
birdnet_network:
ipam:
config:
- subnet: ${IP_SUBNET:-172.25.0.0/24}
volumes:
birdnet:
birdnet_app:
birdnet_recordings:
driver_opts:
type: none
device: ${RECORDS_FOLDER:-/media/data/records}
o: bind

View File

@ -1,24 +1,30 @@
FROM nginx:latest
FROM nginx
ENV PHP_FPM_PORT=${PHP_FPM_PORT:-9000}
ARG SERVER_NAME
ARG PROJECT_ROOT
ARG SYMFONY_PUBLIC
ARG CHARTS_FOLDER
ARG RECORDS_FOLDER
ARG PHP_FPM_HOST
ARG PHP_FPM_PORT
ENV SERVER_NAME=${SERVER_NAME:-birdnet.lan}
ENV PROJECT_ROOT=${PROJECT_ROOT:-/opt/birdnet}
ENV SYMFONY_PUBLIC=${SYMFONY_PUBLIC:-${PROJECT_ROOT}/www/public}
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y nginx-full
USER root
COPY docker/nginx/nginx.conf.template /etc/nginx/sites-available/birdnet.conf
RUN ln -s /etc/nginx/sites-available/birdnet.conf /etc/nginx/sites-enabled/birdnet.conf \
&& sed -i "s|<SERVER_NAME>|${SERVER_NAME}|g" /etc/nginx/sites-available/birdnet.conf \
COPY "docker/nginx/nginx.conf.template" "/etc/nginx/sites-available/birdnet.conf"
RUN ln -s /etc/nginx/sites-available/birdnet.conf /etc/nginx/sites-enabled/birdnet.conf
RUN sed -i "s|<SERVER_NAME>|${SERVER_NAME}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<PHP_FPM_HOST>|${PHP_FPM_HOST}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<PHP_FPM_PORT>|${PHP_FPM_PORT}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<SYMFONY_PUBLIC>|${SYMFONY_PUBLIC}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<RECORDS_DIR>|${RECORDS_DIR}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<CHARTS_DIR>|${CHARTS_DIR}|g" /etc/nginx/sites-available/birdnet.conf
&& sed -i "s|<RECORDS_FOLDER>|${RECORDS_FOLDER}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<CHARTS_FOLDER>|${CHARTS_FOLDER}|g" /etc/nginx/sites-available/birdnet.conf
RUN mkdir -p /etc/nginx/certs/birdnet
WORKDIR /etc/nginx/certs/birdnet
RUN openssl req -x509 -newkey rsa:4096 -keyout privkey.pem -out fullchain.pem -sha256 -days 365 -nodes --subj "/CN=${SERVER_NAME}"
RUN sed -i "s|<CERTIFICATE>|/etc/nginx/certs/birdnet/fullchain.pem|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<PRIVATE_KEY>|/etc/nginx/certs/birdnet/privkey.pem|g" /etc/nginx/sites-available/birdnet.conf
RUN nginx -t
EXPOSE 443
EXPOSE 80

View File

@ -42,15 +42,11 @@ server {
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_pass <PHP_FPM_HOST>:<PHP_FPM_PORT>;
fastcgi_index index.php;
include fastcgi.conf;
}
location /stream {
proxy_pass http://localhost:8000/stream;
}
access_log /var/log/nginx/birdnet-access.log;
error_log /var/log/nginx/birdnet-error.log error;
}

View File

@ -0,0 +1,8 @@
ARG PHP_VERSION=${PHP_VERSION:-8.1}
FROM php:${PHP_VERSION}-fpm
RUN apt-get update && apt-get upgrade -y
RUN docker-php-ext-install pdo_mysql
EXPOSE 9000

View File

@ -1,11 +1,12 @@
ARG PHP_VERSION=${PHP_VERSION:-8.1}
FROM php:${PHP_VERSION}
ENV PROJECT_ROOT=${PROJECT_ROOT:-/opt/birdnet}
ENV SYMFONY_PUBLIC=${SYMFONY_PUBLIC:-${PROJECT_ROOT}/www/public}
ARG PROJECT_ROOT=${PROJECT_ROOT:-/opt/birdnet}
ARG NODE_VERSION=${NODE_VERSION:-16.17.0}
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y \
nginx \
curl \
gzip \
git \
@ -16,8 +17,7 @@ RUN apt-get update && apt-get upgrade -y \
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer
ENV NODE_VERSION="16.17.0"
# Install nodejs and npm
ENV NVM_DIR="/usr/local/nvm"
RUN mkdir ${NVM_DIR}
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
@ -28,29 +28,13 @@ RUN . "$NVM_DIR/nvm.sh" \
&& npm install -g yarn
ENV PATH="$PATH:/usr/local/nvm/versions/node/v${NODE_VERSION}/bin"
WORKDIR ${PROJECT_ROOT}
COPY . ${PROJECT_ROOT}
RUN chown -R www-data:www-data "${PROJECT_ROOT}"
# Install composer dependencies
USER www-data
WORKDIR ${PROJECT_ROOT}/www
USER www-data
# Install composer packages
RUN composer install
# Install yarn dependencies
RUN . "$NVM_DIR/nvm.sh" && yarn install && yarn build
USER root
COPY docker/www/nginx.conf.template /etc/nginx/sites-available/birdnet.conf
RUN ln -s /etc/nginx/sites-available/birdnet.conf /etc/nginx/sites-enabled/birdnet.conf \
&& sed -i "s|<SERVER_NAME>|${SERVER_NAME}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<SYMFONY_PUBLIC>|${SYMFONY_PUBLIC}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<RECORDS_DIR>|${RECORDS_DIR}|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<CHARTS_DIR>|${CHARTS_DIR}|g" /etc/nginx/sites-available/birdnet.conf
RUN mkdir -p /etc/nginx/certs/birdnet
WORKDIR /etc/nginx/certs/birdnet
RUN openssl req -x509 -newkey rsa:4096 -keyout privkey.pem -out fullchain.pem -sha256 -days 365 -nodes --subj "/CN=${SERVER_NAME}"
RUN sed -i "s|<CERTIFICATE>|/etc/nginx/certs/birdnet/fullchain.pem|g" /etc/nginx/sites-available/birdnet.conf \
&& sed -i "s|<PRIVATE_KEY>|/etc/nginx/certs/birdnet/privkey.pem|g" /etc/nginx/sites-available/birdnet.conf
RUN nginx -t
EXPOSE 443
EXPOSE 80
CMD [""]
CMD ["nginx", "-g", "daemon off;"]
CMD ["bash"]

View File

@ -31,7 +31,12 @@ git clone -b main https://github.com/UncleSamulus/BirdNET-stream.git .
Then, run docker-compose:
```bash
docker-compose up
# Build image (first time only)
docker compose up --build
# Run
docker compose up -d
# Stop
docker compose down
```
## Building and running each of the containers