Difference between revisions of "Orchestrating Telstar with Docker Compose"

From Telstar Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Given that a YAML file has been defined and stored in ''docker-compoe.ymal'', the following command will start the docker containers.
    $ docker-compose up -d
To stop the containers, the following command can be used.
    $ docker-compose down
Full details of Docker Compose can be found at https://docs.docker.com/compose/
== Example Docker Compose Yaml Files ==
== Example Docker Compose Yaml Files ==


The following docker-compose yaml file can be used to manage the Telstar application and associated *mongo* database.
The following docker-compose yaml file can be used to manage the Telstar application and associated ''mongo'' database.


     version: "3.8"
     version: "3.8"
Line 7: Line 18:
       telstar-01:
       telstar-01:
         container_name: "telstar-server"
         container_name: "telstar-server"
         image: "johnnewcombe/telstar"
         image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
         command: "server --port 6512 --install" # install to the primary database
         command: "server --port 6512 --init"
         ports:
         ports:
           - target: 6512
           - target: 6512
Line 21: Line 32:
           - mongodb
           - mongodb
         environment:
         environment:
           - TELSTAR_SERVER=AUSTEN
           - TELSTAR_SERVER_DISPLAY_NAME=AUSTEN
       mongodb:
       mongodb:
         container_name: "telstar-mongo"
         container_name: "telstar-mongo"
Line 40: Line 51:
         name: telstar-volume
         name: telstar-volume


The following docker-compose file starts three Telstar servers all talking to the same database server, however the third server (telstar-server-03) inmcludes an environment variable that ensures that it uses the *secondary* database. This *secondary* database collection is typically used to test content before publishing it to the primary database collection. Further details of all of vthe available environment variables can be found in the section [[Configuration Options]]. In addition, the Telstar API is launced as a separate container.
The following docker-compose file starts three Telstar servers all talking to the same database server, however the third server (telstar-server-03) includes an environment variable that ensures that it uses the ''secondary'' database. This ''secondary'' database collection is typically used to test content before publishing it to the primary database collection. Further details of all of the available environment variables can be found in the section [[Configuration Options]]. In addition, the Telstar API is launched as a separate container.


     version: "3.8"
     version: "3.8"
Line 48: Line 58:
         container_name: "telstar-server-01"
         container_name: "telstar-server-01"
         build: .
         build: .
         image: "johnnewcombe/telstar"
         image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
         command: "server --port 6512 --install" # install to the primary database
         command: "server --port 6512 --init" # install to the primary database
         ports:
         ports:
           - target: 6512
           - target: 6512
Line 65: Line 75:
       telstar-02:
       telstar-02:
         container_name: "telstar-server-02"
         container_name: "telstar-server-02"
         image: "johnnewcombe/telstar"
         image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
         command: "server --port 6513"
         command: "server --port 6513"
         ports:
         ports:
Line 82: Line 92:
       telstar-03:
       telstar-03:
         container_name: "telstar-server-03"
         container_name: "telstar-server-03"
         image: "johnnewcombe/telstar"
         image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
         command: "server --port 6514 --install" # install to the secondary database
         command: "server --port 6514 --init" # install to the secondary database
         ports:
         ports:
           - target: 6514
           - target: 6514
Line 100: Line 110:
       telstar-api:
       telstar-api:
         container_name: "telstar-api"
         container_name: "telstar-api"
         image: "johnnewcombe/telstar"
         image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
         command: "api --port 8001 --init"
         command: "api --port 8001 --init"
         ports:
         ports:
Line 110: Line 120:
           - mongodb
           - mongodb
     environment:
     environment:
       - TELSTAR_API_USERID=0 # User 0 has access to all pages
       - TELSTAR_API_USERID=2222222222
       - TELSTAR_API_PASSWORD=telstarapisecret
       - TELSTAR_API_PASSWORD=1234
       - TELSTAR_COOKIE_SECRET=<place yout secret here> # define this for yourself and keep it secret!
       - TELSTAR_COOKIE_SECRET=<place yout secret here> # define this for yourself and keep it secret, a GUID is a good option.
      mongodb:
    mongodb:
        container_name: "telstar-mongo"
      container_name: "telstar-mongo"
        image: "mongo"
      image: "mongo"
        ports:
      ports:
          - target: 27017
        - target: 27017
            published: 27017
          published: 27017
        networks:
      networks:
          telstar-network:
        telstar-network:
        environment:
      environment:
          - MONGO_INITDB_ROOT_USERNAME=mongoadmin
        - MONGO_INITDB_ROOT_USERNAME=mongoadmin
          - MONGO_INITDB_ROOT_PASSWORD=secret
        - MONGO_INITDB_ROOT_PASSWORD=secret
     networks:
     networks:
       telstar-network:
       telstar-network:

Latest revision as of 08:49, 7 May 2022

Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Given that a YAML file has been defined and stored in docker-compoe.ymal, the following command will start the docker containers.

   $ docker-compose up -d

To stop the containers, the following command can be used.

   $ docker-compose down

Full details of Docker Compose can be found at https://docs.docker.com/compose/


Example Docker Compose Yaml Files

The following docker-compose yaml file can be used to manage the Telstar application and associated mongo database.

   version: "3.8"
   services:
     telstar-01:
       container_name: "telstar-server"
       image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
       command: "server --port 6512 --init"
       ports:
         - target: 6512
           published: 6512
       networks:
         - telstar-network
       volumes:
         - type: volume
         source: telstar-volume
         target: /opt/telstar/volume
       depends_on:
         - mongodb
       environment:
         - TELSTAR_SERVER_DISPLAY_NAME=AUSTEN
     mongodb:
       container_name: "telstar-mongo"
       image: "mongo"
       ports:
         - target: 27017
           published: 27017
       networks:
         telstar-network:
       environment:
         - MONGO_INITDB_ROOT_USERNAME=mongoadmin
         - MONGO_INITDB_ROOT_PASSWORD=secret
   networks:
     telstar-network:
       name: telstar-network
   volumes:
     telstar-volume:
       name: telstar-volume

The following docker-compose file starts three Telstar servers all talking to the same database server, however the third server (telstar-server-03) includes an environment variable that ensures that it uses the secondary database. This secondary database collection is typically used to test content before publishing it to the primary database collection. Further details of all of the available environment variables can be found in the section Configuration Options. In addition, the Telstar API is launched as a separate container.

   version: "3.8"
   services:
     telstar-01:
       container_name: "telstar-server-01"
       build: .
       image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
       command: "server --port 6512 --init" # install to the primary database
       ports:
         - target: 6512
           published: 6512
       networks:
         - telstar-network
       volumes:
         - type: volume
         source: telstar-volume
         target: /opt/telstar/volume
       depends_on:
         - mongodb
       environment:
         - TELSTAR_SERVER_DISPLAY_NAME=AUSTEN
     telstar-02:
       container_name: "telstar-server-02"
       image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
       command: "server --port 6513"
       ports:
         - target: 6513
           published: 6513
       networks:
         - telstar-network
       volumes:
         - type: volume
           source: telstar-volume
           target: /opt/telstar/volume
       depends_on:
         - mongodb
       environment:
         - TELSTAR_SERVER_DISPLAY_NAME=ELIOT
     telstar-03:
       container_name: "telstar-server-03"
       image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
       command: "server --port 6514 --init" # install to the secondary database
       ports:
         - target: 6514
           published: 6514
       networks:
         - telstar-network
       volumes:
         - type: volume
           source: telstar-volume
           target: /opt/telstar/volume
       depends_on:
         - mongodb
       environment:
         - TELSTAR_SERVER_DISPLAY_NAME=HARDY
         - TELSTAR_DBCOLLECTION=SECONDARY
     telstar-api:
       container_name: "telstar-api"
       image: "johnnewcombe/telstar:amd64-2.0-RC3.23"
       command: "api --port 8001 --init"
       ports:
         - target: 8001
           published: 8001
       networks:
         - telstar-network
       depends_on:
         - mongodb
   environment:
     - TELSTAR_API_USERID=2222222222
     - TELSTAR_API_PASSWORD=1234
     - TELSTAR_COOKIE_SECRET=<place yout secret here> # define this for yourself and keep it secret, a GUID is a good option.
   mongodb:
     container_name: "telstar-mongo"
     image: "mongo"
     ports:
       - target: 27017
         published: 27017
     networks:
       telstar-network:
     environment:
       - MONGO_INITDB_ROOT_USERNAME=mongoadmin
       - MONGO_INITDB_ROOT_PASSWORD=secret
   networks:
     telstar-network:
       name: telstar-network
   volumes:
     telstar-volume:
       name: telstar-volume