docker: Update docker-compose and ./docker Dockerfiles
This commit is contained in:
parent
048e93fef0
commit
c1af47eb26
@ -5,3 +5,6 @@ var
|
|||||||
media
|
media
|
||||||
daemon/systemd
|
daemon/systemd
|
||||||
analyzer
|
analyzer
|
||||||
|
vendor
|
||||||
|
node_modules
|
||||||
|
build
|
10
.env
10
.env
@ -3,10 +3,10 @@ CUDA_VISIBLE_DEVICES=""
|
|||||||
|
|
||||||
# BirdNET-stream environment
|
# BirdNET-stream environment
|
||||||
DATABASE_USER="birdnet"
|
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
|
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"
|
RECORDS_FOLDER=/media/DATA/birdnet/records/
|
||||||
CHARTS_FOLDER="./var/charts"
|
CHARTS_FOLDER=/media/DATA/birdnet/charts/
|
||||||
SERVER_NAME="birdnet.lan"
|
SERVER_NAME="birdnet.local"
|
12
.env.example
Normal file
12
.env.example
Normal 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"
|
@ -10,67 +10,101 @@ services:
|
|||||||
# environment:
|
# environment:
|
||||||
# - CHUNK_FOLDER=${CHUNK_FOLDER:-/media/birdnet/records}
|
# - CHUNK_FOLDER=${CHUNK_FOLDER:-/media/birdnet/records}
|
||||||
# volumes:
|
# volumes:
|
||||||
# - ./var/:/media/birdnet/records
|
# - ${RECORDS_FOLDER:-/media/birdnet/records}:${RECORS_FOLDER:-/media/birdnet/records}
|
||||||
# # Allow container to access to the hosts microphone
|
# # Allow container to access to the hosts microphone
|
||||||
# devices:
|
# devices:
|
||||||
# - /dev/snd
|
# - /dev/snd:/dev/snd
|
||||||
|
|
||||||
# analyzer:
|
# analyzer:
|
||||||
# container_name: birdnet_analyzer
|
# container_name: birdnet_analyzer
|
||||||
# build:
|
# build:
|
||||||
# context: ./analyzer/
|
# context: ./analyzer/
|
||||||
# dockerfile: ./Dockerfile
|
# 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:
|
php-fpm:
|
||||||
# container_name: birdnet_database
|
container_name: birdnet_php-fpm
|
||||||
# image: mariadb:latest
|
image: php:${PHP_VERSION:-8.1}-fpm
|
||||||
# command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
ports:
|
||||||
# ports:
|
- ${PHP_FPM_PORT:-9000}:9000
|
||||||
# - '3307:3306'
|
networks:
|
||||||
# networks:
|
birdnet_network:
|
||||||
# - birdnet_network
|
restart: unless-stopped
|
||||||
# environment:
|
volumes:
|
||||||
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-secret}'
|
- birdnet_app:${PROJECT_ROOT:-/opt/birdnet}
|
||||||
# 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
|
|
||||||
|
|
||||||
symfony:
|
symfony:
|
||||||
container_name: birdnet_symfony
|
container_name: birdnet_symfony
|
||||||
hostname: birdnet.symfony
|
networks:
|
||||||
|
birdnet_network:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./docker/symfony/Dockerfile
|
dockerfile: ./docker/symfony/Dockerfile
|
||||||
environment:
|
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
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
networks:
|
- birdnet_app:${PROJECT_ROOT:-/opt/birdnet}
|
||||||
- birdnet_network
|
- birdnet_recordings:${RECORDS_FOLDER:-/media/birdnet/records}
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
container_name: birdnet_nginx
|
container_name: birdnet_nginx
|
||||||
hostname: birdnet.nginx
|
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./docker/nginx/Dockerfile
|
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:
|
ports:
|
||||||
- '81:80'
|
- '80:80'
|
||||||
- '444:443'
|
- '443:443'
|
||||||
environment:
|
volumes:
|
||||||
- PHP_FPM_PORT=${PHP_FPM_PORT:-9001}
|
- birdnet_app:${RECORDS_FOLDER-/opt/birdnet}
|
||||||
- PHP_FPM_HOST=${PHP_FPM_HOST:-birdnet.php-fpm}
|
- birdnet_recordings:${RECORDS_FOLDER-/media/data/records}
|
||||||
networks:
|
networks:
|
||||||
- birdnet_network
|
birdnet_network:
|
||||||
|
ipv4_address: ${IP_ADDRESS:-172.25.0.101}
|
||||||
|
aliases:
|
||||||
|
- ${SERVER_NAME:-birdnet.local}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- symfony
|
||||||
|
- php-fpm
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
birdnet_network:
|
birdnet_network:
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: ${IP_SUBNET:-172.25.0.0/24}
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
birdnet:
|
birdnet_app:
|
||||||
|
|
||||||
|
birdnet_recordings:
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ${RECORDS_FOLDER:-/media/data/records}
|
||||||
|
o: bind
|
@ -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}
|
RUN apt-get update && apt-get upgrade -y \
|
||||||
ENV PROJECT_ROOT=${PROJECT_ROOT:-/opt/birdnet}
|
&& apt-get install -y nginx-full
|
||||||
ENV SYMFONY_PUBLIC=${SYMFONY_PUBLIC:-${PROJECT_ROOT}/www/public}
|
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
COPY docker/nginx/nginx.conf.template /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 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 \
|
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|<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|<RECORDS_FOLDER>|${RECORDS_FOLDER}|g" /etc/nginx/sites-available/birdnet.conf \
|
||||||
&& sed -i "s|<CHARTS_DIR>|${CHARTS_DIR}|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
|
RUN mkdir -p /etc/nginx/certs/birdnet
|
||||||
WORKDIR /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 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 \
|
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
|
&& sed -i "s|<PRIVATE_KEY>|/etc/nginx/certs/birdnet/privkey.pem|g" /etc/nginx/sites-available/birdnet.conf
|
||||||
RUN nginx -t
|
|
||||||
|
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
@ -42,15 +42,11 @@ server {
|
|||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_split_path_info ^(.+\.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;
|
fastcgi_index index.php;
|
||||||
include fastcgi.conf;
|
include fastcgi.conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /stream {
|
|
||||||
proxy_pass http://localhost:8000/stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
access_log /var/log/nginx/birdnet-access.log;
|
access_log /var/log/nginx/birdnet-access.log;
|
||||||
error_log /var/log/nginx/birdnet-error.log error;
|
error_log /var/log/nginx/birdnet-error.log error;
|
||||||
}
|
}
|
||||||
|
8
docker/php-fpm/Dockerfile
Normal file
8
docker/php-fpm/Dockerfile
Normal 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
|
@ -1,11 +1,12 @@
|
|||||||
ARG PHP_VERSION=${PHP_VERSION:-8.1}
|
ARG PHP_VERSION=${PHP_VERSION:-8.1}
|
||||||
|
|
||||||
FROM php:${PHP_VERSION}
|
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 \
|
RUN apt-get update && apt-get upgrade -y \
|
||||||
&& apt-get install -y \
|
&& apt-get install -y \
|
||||||
nginx \
|
|
||||||
curl \
|
curl \
|
||||||
gzip \
|
gzip \
|
||||||
git \
|
git \
|
||||||
@ -16,8 +17,7 @@ RUN apt-get update && apt-get upgrade -y \
|
|||||||
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
|
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
|
||||||
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
# Install nodejs and npm
|
||||||
ENV NODE_VERSION="16.17.0"
|
|
||||||
ENV NVM_DIR="/usr/local/nvm"
|
ENV NVM_DIR="/usr/local/nvm"
|
||||||
RUN mkdir ${NVM_DIR}
|
RUN mkdir ${NVM_DIR}
|
||||||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
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
|
&& npm install -g yarn
|
||||||
ENV PATH="$PATH:/usr/local/nvm/versions/node/v${NODE_VERSION}/bin"
|
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}"
|
RUN chown -R www-data:www-data "${PROJECT_ROOT}"
|
||||||
# Install composer dependencies
|
|
||||||
USER www-data
|
|
||||||
WORKDIR ${PROJECT_ROOT}/www
|
WORKDIR ${PROJECT_ROOT}/www
|
||||||
|
USER www-data
|
||||||
|
# Install composer packages
|
||||||
RUN composer install
|
RUN composer install
|
||||||
# Install yarn dependencies
|
# Install yarn dependencies
|
||||||
RUN . "$NVM_DIR/nvm.sh" && yarn install && yarn build
|
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
|
CMD ["bash"]
|
||||||
EXPOSE 80
|
|
||||||
CMD [""]
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
@ -31,7 +31,12 @@ git clone -b main https://github.com/UncleSamulus/BirdNET-stream.git .
|
|||||||
Then, run docker-compose:
|
Then, run docker-compose:
|
||||||
|
|
||||||
```bash
|
```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
|
## Building and running each of the containers
|
||||||
|
Loading…
Reference in New Issue
Block a user