Skip to content

Latest commit

 

History

History
132 lines (99 loc) · 2.7 KB

developer.md

File metadata and controls

132 lines (99 loc) · 2.7 KB

BDMS

Start the service for developlemnt

Start the minio service

Enter the minio folder:

cd ./minio

Create an .env file, and add the following lines:

MINIO_ROOT_USER=THE_USER_NAME
MINIO_ROOT_PASSWORD=THE_PASSWORD

Then start minio:

docker-compose up -d

Start the bms service manually

Starting from the project root, run the following command, create the .credentials, and add the following lines:

[default]
aws_access_key_id = THE_MINIO_ROOT_USER_USED_ABOVE
aws_secret_access_key = THE_MINIO_ROOT_PASSWORD_USED_ABOVE

Then start the bms service:

cd ./service-bdms
docker run --rm -it \
    --network="host" \
    --name swissforages-service \
    -v $PWD:/workspace \
    -w /workspace \
    swisstopo/service-bdms:latest \
    python bms/main.py \
        --pg-auto-upgrade \
        --pg-database=bdms \
        --smtp_config=./config/smtp.conf \
        --s3-bucket=bdms \
        --s3-credentials-file=/workspace/.credentials \
        --s3-endpoint=localhost:9000 \
        --s3-secure=False

Database upgrades

BDMS database can have some modification during development. All the SQL commands shall be stored into the ./bdms/assets/sql folder.

The name of the file is formatted as follows:

{previews_version}to{current_version}.sql

Example: 1.0.2_to_1.0.3.sql

The in the main.py file the automatic upgrade process shall be configured in the following manner:

# Database version
__version__ = '1.0.3'

# (...)

# Ordered list of upgradable versions
versions = [
    "1.0.0",
    "1.0.1",
    "1.0.2"
]

# SQL upgrades directory
udir = "./bms/assets/sql/"

# SQL to execute for upgrades
sql_files = {
    "1.0.0": f"{udir}1.0.0_to_1.0.1.sql",
    "1.0.1": f"{udir}1.0.1_to_1.0.2.sql",
    "1.0.2": f"{udir}1.0.2_to_1.0.3.sql",
}

And the executing the main with the parameter pg_auto_upgrade the upgrade will be executed automatically.

Build Docker image

Build release candidate on github image:

version=$(cat ./VERSION.txt)
username=geoadmin
DOCKER_BUILDKIT=1 \
    docker build \
        -t ghcr.io/$username/service-bdms/service-bdms:$version .

Build image (dockerhub ready):

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

Run Docker container manually

First time run container

docker run --rm -it \
  --network="host" \
  --name bdms-service \
  -v $PWD:/workspace \
  -w /workspace \
  swisstopo/service-bdms:latest \
  python bms/main.py \
    --pg-auto-upgrade \
    --pg-database=bdms \
    --smtp_config=./config/smtp.conf \
    --s3-bucket=bdms \
    --s3-credentials-file=/workspace/.credentials \
    --s3-endpoint=localhost:9000 \
    --s3-secure=False