Disclaimer

This document is only collection of author’s notes, experiences and point of views. It is not, in any meaning, either complete description of the topic nor official RTB documentation. It may be inaccurate, incomplete, obsolete, misleading or completely wrong. It may even cause loss of data or damage system integrity. It may not comply with company codex, values, presentation style or economic interests or may reveal company secrets.

As such, it is absolutely prohibited to distribute this document outside of RTB & Co. GmbH. Such an action may result into legal acts against both the sender and the company. It is only intended, after review of technical and presentational correctness and accuracy, to be used as an information source for official documentation.

Always contact documentation department for information about current presentation style and allowed formats before creating customer’s documentation.

This article describes how to use and deploy containerized PDM.control to various environments.

1. Container

A container is automatically build on predefined branches (see file .gitlab-ci.yml). Image is stored in Gitlab’s container registry. It can be used from there.

Describe how to log in.

2. Tags

There are various tags for releases and development. Some branches intended to be deployed to staging (or some other environment) produces also image.

2.1. General

Latest build from (selected branches) gets two tags. Both of them are prefixed by dev. They are not intended to be used in production.

Branch:

  • Build from branch is labeled by branch name and pipeline ID. E.g. dev-next-4584

  • Latest build from a branch is tagged by branch name. E.g. dev-next

2.2. Releases

Additionally to general tags following release tags are also applied. Every release is tagged with all release components and latest. For example there is release 1.2.3. Following tags will be applied to this release

  • 1

  • 1.2

  • 1.2.3

  • latest

It guarantees that container can be upgraded based on user intention. E.g. specifying tag 1.2 will install latest patch but keep minor version.

3. Usage

3.1. Configuration

Absolute mininum to let PDM.control to start is to define following properties.

spring.datasource.url=jdbc:postgresql://db:5432/pdm
spring.datasource.username=pdm_control
spring.datasource.password=pdm_control
pcon.wan.ip=80.228.56.178
pcon.app.url=http://localhost:8080

By classic deployments are those properties set inside of application.properties or application.yaml file.

There are tow ways how to provide those properties to containerized application.

3.1.1. Environment variables

Spring reads properties from environment variables as well. They have precedence to properties defined in file. Therefore properties can be injected to run time environment like this.

SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/pdm
SPRING_DATASOURCE_USERNAME=pdm_control
SPRING_DATASOURCE_PASSWORD=pdm_control
PCON_WAN_IP=80.228.56.178
PCON_APP_URL=http://localhost:8080/

Please note, that dots (.) in property names are replaced by underscores (_).

3.1.2. Configuration file

Configuration directory be mounted to the container to path /pdm_control/config. It may contain various configuration files. It can be mounted to the container as -v $(pwd)/config:/pdm_control/config. The name of configuration file must be one of application.properties or application.yaml. The file which was used for configuration in classic deployment can be used.

3.2. Ports

There are tow ports which can be exposed.

  • 8080: Tomcat port for HTTP connections from web browser.

  • 52000: TCP port used by PDMs to connect server.

4. Example deployments

PDM.control requires also PostgreSQL database to operate. Here is an example configuration for docker-compose to bring whole system up.

version: '3.8'
services:
  # PostgreSQL
  db:
    # image to fetch from docker hub
    image: postgres:15
    container_name: postgres
    environment:
        # Super-user password. Not used by PDM.control.
      - "POSTGRES_PASSWORD=example"
    volumes:
      - postgres-data:/var/lib/postgresql/data
      - ./db_init:/docker-entrypoint-initdb.d
    networks:
      - pdm

  # PDM.control
  pdm_control:
    image: "docker.rtb-bl.de/pdm/central/pdm_control:dev-f_docker"
    container_name: pdm_control
    environment:
      - "SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/pdm"
      - "SPRING_DATASOURCE_USERNAME=pdm_control"
      - "SPRING_DATASOURCE_PASSWORD=pdm_control"
      - "PCON_WAN_IP=80.228.56.178"
      - "PCON_APP_URL=http://localhost:8080/"
    volumes:
      - ./pdm_control_config:/pdm_control/config
    ports:
      - 8080:8080
    networks:
      - pdm
    depends_on:
      - db

# Networks
networks:
  pdm:
    driver: bridge

# Volumes
volumes:
    postgres-data:
      external: false
    pg_admin:
      external: false

The whole deployment can be done by single command:

$ docker-compose up

Please note, that in order to be able to access container registry form RTB you need to log in fist log in.

$ docker login docker.rtb-bl.de
Your password will be stored unencrypted in /home/<user_name>/.docker/config.json. Do not forget to log out on untrusted computers. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store

See complete configuration of deployment for staging environment.