Skip to content

The official swissforages.ch Web Service API exposing access to manage and view data of the Federal Borehole Data Model of Switzerland.

License

Notifications You must be signed in to change notification settings

ist-supsi/service-bdms

 
 

Repository files navigation

Borehole Management System Service

Installation

sudo apt-get install \
    unzip \
    python3.7 \
    python3-pip \
    nginx \
    nano \
    npm \
    git \
    postgresql \
    postgresql-contrib \
    postgis \
    libsqlite3-mod-spatialite 

Database initilization

Create the database

sudo -u postgres createdb -E UTF8 bdms

Create the tables:

sudo -u postgres psql -d bdms -f db/1_schema.sql

Add default data:

sudo -u postgres psql -d bdms -f db/2_data.sql
sudo -u postgres psql -d bdms -f db/3_cantons.sql
sudo -u postgres psql -d bdms -f db/4_municipalities.sql

Or remotly with port forwarding:

ssh -R 9432:localhost:5432 USER_NAME@IP_ADDRESS

And then:

psql -U postgres -d bdms -h localhost -p 9432 -f db/1_schema.sql
psql -U postgres -d bdms -h localhost -p 9432 -f db/2_data.sql
psql -U postgres -d bdms -h localhost -p 9432 -f db/3_cantons.sql
psql -U postgres -d bdms -h localhost -p 9432 -f db/4_municipalities.sql

Run Server

Setup virtual environment

sudo apt-get install python3-venv
python3.7 -m venv ./venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

Activate virtual environment

source venv/bin/activate

Run Server

python bms/main.py --pg-database=bdms

Config parameters:

--pg-database      PostgrSQL database name (default bms)
--pg-host          PostgrSQL database host (default localhost)
--pg-password      PostgrSQL user password (default postgres)
--pg-port          PostgrSQL database port (default 5432)
--pg-user          PostgrSQL database user (default postgres)
--pg-upgrade       Upgrade PostgrSQL schema (default false)
--port             Tornado Web port (default 8888)

Run with docker

Installation

Docker install:

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Git install:

sudo apt-get install git

Build docker image from source

Clone server repository, and run the build command.

git clone https://github.com/geoadmin/service-bdms.git
cd service-bdms
version=$(cat ./VERSION.txt)
docker build -t swisstopo/service-bdms:$version .

If you are preparing a beta version:

version=$(cat ./VERSION.txt)-beta.$(date +%Y%m%d)
docker build -t ghcr.io/geoadmin/service-bdms/service-bdms:$version .
docker push ghcr.io/geoadmin/service-bdms/service-bdms:$version

Stable release:

version=$(cat ./VERSION.txt)
docker build -t swisstopo/service-bdms:$version .
docker push swisstopo/service-bdms:$version

Run docker container

Run Docker container (x.x.x is the release number, start with 1.0.0):

N.B. Run with Docker-compose is preferred, please see docker-compose.yml.

docker run --rm -it \
    --name service-bdms-test \
    --network="host" \
    -e DB_HOST='localhost' \
    -e FILE_STORAGE='s3' \
    -e S3_ENDPOINT='localhost:9000' \
    -e S3_SECURE='0' \
    -e S3_BUCKET='bdms' \
    -e S3_CREDENTIALS_FILE='/usr/src/app/credentials' \
    -v /home/milan/workspace/swisstopo/credentials:/usr/src/app/credentials \
    swisstopo/service-bdms:1.0.4-beta.20211109

Run Docker container and enter bash:

docker run --rm \
    --name service-bdms-test \
    --network="host" \
    -e DB_HOST='localhost' \
    swisstopo/service-bdms:1.0.4

About

The official swissforages.ch Web Service API exposing access to manage and view data of the Federal Borehole Data Model of Switzerland.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.7%
  • Other 0.3%