Server installation#
There are different ways to install DigiAgriApp server, it is suggested to use Podman/Docker solution but if you cannot do it there is the native installation.
Running with Podman#
Podman is a software to manage containers, pods and images, it can run on different platform including Linux, Windows and Mac. Its power is that you can run it as normal user instead of an administrator of the computer/server.
Requirements#
Install dependencies:
Podman
Podman-compose
Git
Debian < 12#
apt install git podman python3-pip
pip3 install podman-compose
Debian >= 12#
apt install git podman podman-compose
Ubuntu < 24#
sudo apt install git podman python3-pip
sudo pip3 install podman-compose
Ubuntu >= 24#
sudo apt install git podman podman-compose
Instructions#
First clone the DigiAgriApp server repository
git clone https://gitlab.com/digiagriapp/digiagriapp-server
Next steps is to run the Podman service, this is required to run podman containers, remember to start the Podman service with the user that you will use to run DigiAgriApp containers (we suggest to not run as root user)
podman system service --time=0 unix:///run/user/1000/podman.sock
/run/user/1000/podman.sock
is the path to the Podman socket, you can use any path where the user can write;
this path will be used later in the configuration. As socket you can also use TCP url.
At this point enter in the docker
folder inside digiagriapp-server
directory and now it is possible to build the needed images with
podman-compose -f compose.yml build
Finally you can start the containers; using DOCKER_SOCK=/run/user/1000/podman.sock
we are telling to Podman
to use the Podman socket created before
DOCKER_SOCK=/run/user/1000/podman.sock podman-compose -f compose.yml up -d
You can also modify permanently the socket changing the compose.yml
file.
The are some lines to change, using Podman it is required to modify
${DOCKER_SOCK:-/var/run/docker.sock}:/var/run/docker.sock:ro
with
${DOCKER_SOCK:-/run/user/1000/podman.sock}:/var/run/docker.sock:ro
At this point you should be able to reach DigiAgriApp server admin panel using a browser and going to https://digiagriapp.containers.localhost:8443/agriadm
Running in production with Let’s encrypt#
When you use this solution in production you need also to change some other lines in the compose.yml
file:
remove the
test
containerremove this line
--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
replace the host name
digiagriapp.containers.localhost
with your address
Running in production with your own SSL certificate#
TODO
Running with Docker#
Docker is a platform for developing, shipping and running application using containers. It’s similar to Podman but it is run as administrator.
Requirements#
Install dependencies:
Docker
Docker-compose
Git
Debian/Ubuntu#
sudo apt install git docker docker-compose
Instructions#
First clone the DigiAgriApp server repository
git clone https://gitlab.com/digiagriapp/digiagriapp-server
Enter in the docker
folder inside digiagriapp-server
folder and it is possible can build the needed images and start all the needed services
docker-compose -f compose.yml build
docker-compose -f compose.yml up -d
Running in production#
Please refer to the previous Podman Running in production section
Running with native installation#
With this solution you don’t use any container and install all the needed software on your machine.
Requirements#
Install dependencies:
Python 3 >= 3.7
PostgreSQL
PostGIS
Proj4
GDAL
redis
Git
Debian#
apt install git proj-bin python3 postgresql postgis gdal-bin libproj-dev libgeos-dev libpq-dev redis
Ubuntu#
sudo apt install git proj-bin python3 postgresql postgis gdal-bin libproj-dev libgeos-dev libpq-dev redis
First steps#
Please clone the DigiAgriApp server repository
git clone https://gitlab.com/digiagriapp/digiagriapp-server
Set two needed environment variables to download and install the correct Python GDAL and Proj version.
To get the Proj version run in the command line proj
. For Proj please refer to the
compatibility matrix table,
for example if you have Proj 8.2.1 you can set PROJ_VER=”3.4.1”
export GDAL_VER=`gdal-config --version`
export PROJ_VER="3.4.1"
Enter in the directory and create the Python environment, activate it and install the needed libraries
cd digiagriapp-server
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Create the database, you can choose between different ones but we really suggest to use PostgreSQL with the PostGIS extension.
createdb digiagri
psql -c "CREATE EXTENSION postgis" digiagri
psql -c "CREATE EXTENSION postgis_raster" digiagri
Make a copy of src/DigiAgriApp/template_settings.py
file, rename it to src/DigiAgriApp/settings.py
, and set up the right parameters for PostgreSQL user and MQTT if you need it.
At this point initialize the database
python src/manage.py makemigrations core data experiment field infrastructure irrigation machinery maintenance observation operation plant production remotesensing treatment waste
python src/manage.py migrate
Testing#
Run Django app#
python src/manage.py runserver
WARNING
Each time you execute the file make sure you activated the python environment
create admin user for digiagriapp#
python src/manage.py createsuperuser
Run Celery#
DJANGO_SETTINGS_MODULE='DigiAgriApp.settings' celery -A DigiAgriApp worker -l INFO
Production with uwsgi#
Django configuration#
Install uwsgi
library
pip install uwsgi
Modify the ini file, to fix the full paths
vim src/digiagriapp.ini
Create the log directory
mkdir log
Run uwsgi
uwsgi src/digiagriapp.ini
To look the log you can use tail
command
tail -f log/uwsgi.log
To be exposed to internet you need a HTTP server like Apache or NGIX
Celery configuration#
Copy the service template to the right systemd folder and modify it fixing all the paths
sudo cp src/conf/template_celery.service /etc/systemd/system/
Copy the Celery configuration file from the template template_celery.conf
and fix the paths
cp src/conf/template_celery.conf src/conf/celery.conf
Start the celery system with
sudo systemctl start celery.service
If you facing problem starting Celery you can try inside the src
folder