Installation Vagrant

Installation as virtual Maschine with Vagrant.

create a folder on the Host Maschine and change to that dir:

mkdir /usr/share/t2core/

Create a Enviroment File /usr/share/t2core/.env:

PWD=./
DOCKER_REGISTRY=docker.io
DOCKER_PROJECT=tri2
DOCKER_TAG=latest
T2CORE_SECRET_KEY=dosiufzgd89f7gzjd8f7zgjSEFSfesEFEWFgHjk98dfzsj098dzfj
T2CORE_DATABASE_PASSWORD=sdlfihsmd9f8zgsDFSDfef8sdzgfsRGD8dzgfsz8df

Change the shown T2CORE_SECRET_KEY and T2CORE_DATABASE_PASSWORD as this are only the default Values.

Create a File /usr/share/t2core/docker-compose.yml:

version: "2.2"
services:

  t2_core:
    image: "${DOCKER_REGISTRY}/${DOCKER_PROJECT}/t2-core:${DOCKER_TAG}"
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ${PWD}/t2core_data:/data:rw
    environment:
      # enables debug mode in django. this is very insecure. __do__ __not__ enable it, when django runs on a public environment!
      DEBUG: "false"
      START_PAGE_APP_URL: 't2ldap.urls'
      SECRET_KEY: "${T2CORE_SECRET_KEY}"
      IMPORTER_NETWORK_NAME_PREFIX: "localhost_"
      DATABASE_HOST: "database"
      DATABASE_PORT: "5432"
      DATABASE_NAME: "t2_core"
      DATABASE_USERNAME: "t2core"
      DATABASE_PASSWORD: "${T2CORE_DATABASE_PASSWORD}"
      DOCKER_REGISTRY: "${DOCKER_REGISTRY}"
      DOCKER_PROJECT: "${DOCKER_PROJECT}"
      DOCKER_TAG: "${DOCKER_TAG}"

    networks:
      - internal
    links:
      - "t2_database:database"
    labels:
      traefik.enable: "true"
      traefik.docker.network: "t2core_router"
      traefik.frontend.passhostheader: "False"
      traefik.http.routers.t2_core.entrypoints: "web"
      traefik.http.routers.t2_core.rule: "PathPrefix(`/`)"
      traefik.http.routers.t2_core.service: "t2_core"

      traefik.http.routers.t2_core_s.entrypoints: "websecure"
      traefik.http.routers.t2_core_s.rule: "PathPrefix(`/`)"
      traefik.http.routers.t2_core_S.service: "t2_core"
      traefik.http.routers.t2_core_S.tls: ""

      traefik.http.services.t2_core.loadbalancer.server.port: "8000"
      traefik.http.services.t2_core.loadbalancer.server.scheme: "http"

      traefik.tcp.routers.t2_ldapproxy.entrypoints: "ldap"
      traefik.tcp.routers.t2_ldapproxy.rule: "HostSNI (`*`)"
      traefik.tcp.routers.t2_ldapproxy.service: "t2_ldapproxy"#
      traefik.tcp.routers.t2_ldapproxy_s.entrypoints: "ldapsecure"
      traefik.tcp.routers.t2_ldapproxy_s.rule: "HostSNI (`*`)"
      traefik.tcp.routers.t2_ldapproxy_s.service: "t2_ldapproxy"
      traefik.tcp.routers.t2_ldapproxy_s.tls: ""
      traefik.tcp.services.t2_ldapproxy.loadbalancer.server.port: "389"


  t2_database:
    image: postgres:13
    restart: always
    volumes:
      - t2core_database:/data:rw
    environment:
      POSTGRES_PASSWORD: "${T2CORE_DATABASE_PASSWORD}"
      POSTGRES_USER: "t2core"
      POSTGRES_DB: "t2_core"
      PGDATA: "/data"
    networks:
      - internal


volumes:
  t2core_database:

networks:
  # internal network between django and its database
  internal:

Bemerkung

Database version: the postgres database version must be set to a major version (postgres:12, postgres:13), because database files are not compatible between major versions. Currently this is version 13, installations can be migrated between versions, but this cannot be done automatically. See https://www.postgresql.org/docs/current/upgrading.html and https://github.com/docker-library/postgres/issues/766

Create a File /usr/share/t2core/Vagrantfile with this content:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "geerlingguy/ubuntu2004"
  config.vm.hostname = "t2core"
  # http/https extern
  config.vm.network "forwarded_port", guest: 80,   host: 4500, host_ip: "0.0.0.0"
  config.vm.network "forwarded_port", guest: 443,  host: 4501, host_ip: "0.0.0.0"

  # importer entrypoint extern
  config.vm.network "forwarded_port", guest: 81,  host: 4504, host_ip: "0.0.0.0"

  # traefik dashboard extern
  config.vm.network "forwarded_port", guest: 8080, host: 4502, host_ip: "0.0.0.0"

  # ldap extern
  config.vm.network "forwarded_port", guest: 636,  host: 4503, host_ip: "0.0.0.0"
  # ldap extern
  config.vm.network "forwarded_port", guest: 389,  host: 4505, host_ip: "0.0.0.0"

  #
  config.vm.provider "virtualbox" do |vb|
     vb.memory = "4096"
     vb.cpus = "4"
  end
  config.vm.provision "shell", inline: <<-SHELL
     apt-get update
     apt-get install -y python3-pip docker.io
     python3 -m pip install pip --upgrade && python3 -m pip install docker docker-compose && \
     mkdir -p /usr/share/t2core/ && \
     cp /vagrant/docker-compose.yml /usr/share/t2core/docker-compose.yml && \
     cp /vagrant/.env /usr/share/t2core/.env && \
     cd /usr/share/t2core/ && \
     docker-compose pull && \
     docker-compose up -d --build --remove-orphans && \
     echo "\n\nInstall complete. t2core should be \n\thttp://localhost:4500\n\thttps://localhost:4501\nA new User root was created. You find its Password in the Container Logs.\n" && \
     echo "to set a new superuser:\n\n\t vagrant ssh -c 'sudo docker exec -it t2core_t2_core_1 ./manage.py createsuperuser'\n\n"
  SHELL
end

then start vagrant in /usr/share/t2core/:

vagrant up --provision

after a while the server starts, a admin account root is generated and its password is written to the container logs once:

docker-compose logs t2_core
t2_core_1      | new password of user "root" is:
t2_core_1      |
t2_core_1      |                5e425930-a8d2-4d97-bfe0-18a6df19c66c

Bemerkung

this is a random generated password. the one shown here will not work on your maschine.

the install is done now if you are able to login and you can proceed to the configuration.