Skip to content

Latest commit

 

History

History
93 lines (57 loc) · 6.59 KB

ErewhonExample2.md

File metadata and controls

93 lines (57 loc) · 6.59 KB

Erewhon Example 2 - Deploying your first containers

These instructions will start JADE database and application servers running in containers, allowing you to connect to the database with a thin client. If you haven't already, make sure you follow the instructions in Getting Started before proceeding further. Completing Erewhon Example 1 before this example is recommended but not required.

Quick Setup

If you want to skip the detailed instructions, you can run a script which will perform the steps automatically. This script will perform the steps in Erewhon Example 1 as well as deploying the containers, however if you have already done that example, the database setup steps will be skipped.

If you have done the Erewhon Example 1, you will have already completed the following. If not, do it now.

This script will create a dedicated database for use with the example, so you may need to specify where to put that database to avoid it interfering with any existing database on your computer:

  • Modify the run-config.ps1 script in the \examples\config\ folder:
    • Set the $jadeRootDirectory variable to the path where you want the database generated.
    • Change $licenceName and $licenceKeys if you want to use your own. A free licence key is defined as a default.

You can now run the deploy.ps1 script from the \examples\Erewhon-example-2-AppServer\ folder.

The deploy.ps1 script will generate a database at the path specified in the $jadeRootDirectory variable and apply a licence to it. It will then load the Erewhon schemas into the database and import the example data. It will finally start a database server and application server. Before each step it will check if the step has already been done, and only perform that step if needed.

You can now run the thin-client.ps1 script from the \shortcuts\ folder to connect to the application server with a thin client.

Manual Setup

For the manual setup, the details of Erewhon Example 1 will not be repeated. If you haven't done that example already, either follow the manual instructions in Erewhon Example 1 or run the \examples\Erewhon-Example-1-LoadData\deploy.ps1 script.

Deploying the host database

Now that we have a database, we want to run it in its own container. To start the container running a database server, we can use the examples\Database-Server-Container\deploy.ps1 script. This uses docker compose to start the container described in the docker-compose.yml file in the same folder.

If we inspect this docker-compose.yml we can see what it's doing: The service name is specified as 'jade-rap', and under this heading are the following headings.

  • image: This is the image which the container will be based on, in our case a 64bit unicode version of JADE 2020 database server from the registry (as set in the config\run-config.ps1 script.)
  • volumes: These are the filepaths on the host machine that will be mapped to the file system of the container. This means that when the container accesses the system, journals or logs directory, it's accessing directories on the host.
  • ports: Maps a port on the host to a port on the container - when the host gets a request on the port 9901, it will forward it to the container who will receive it on its port 9901.

Deploying an application server with docker run

There are several ways to deploy or run containers. In the first step of this example we used a docker-compose.yml file and the powershell docker compose up -d command.

Just so that we can see another way, run the following PowerShell command:

docker run -d -p 443:9907 --name jade-app-server --volume c:\Erewhon\logs:c:\jade\logs  registry.jadeworld.io/jade/application-server:22.0.02-x64-U

This will download and deploy the application server image from the JADE registry, bind port 443 on the host to port 9907 in the container, and bind the directory C:\Erewhon\logs to the logs directory in the container - this will allow you to view the logs generated in the container on the host. (If your database is located elsewhere than c:\Erewehon\jade, change that part of the path as required.)

To verify that the application server is up and running, you can run the \scripts\thin-client.ps1 to connect to it with a thin client.

Deploying both servers using docker compose

If we want to start both containers with one step, we can define multiple containers in a single docker-compose.yml file and run it using the \examples\Erewhon-Example-2-Appserver\deploy.ps1 script.

When you run the aforementioned script, you should see an errors come up. The name of the container is already in use because we still have a database and an application server running. To stop these containers, run the \examples\Database-Server-Container\stop.ps1 script.

Once you have run the script, to check that it was successful you can run the following Powershell command:

docker ps

You should see no running containers. But there is still a container running - the application server can't run without the database server, so the container has stopped but it hasn't been removed yet. You can see it with the following PowerShell command:

docker container ls -a

To remove it, use the following PowerShell command:

docker container rm jade-app-server

Now, when you run the deploy.ps1 script from the \examples\Erewhon-Example-2-Appserver folder, it should start up the two containers without error. You can use the scripts\thin-client.ps1 script to verify that you can connect to the application server.

One advantage of using a single docker-compose.yml for multiple containers is that it's easy to start and stop related containers together. For example, if you run the \examples\Erewhon-Example-2-Appserver\stop.ps1 script, it will stop both of the containers together.

Using the Erewhon demo environment

At this stage you should have a JADE database server and a JADE application server running in containers, ready for a thin client connection.

You may like to try any of the following.

  • You can start a thin client IDE using the thin-client-ps1 script in the /shortcuts/ folder.
  • You can start the Erewhon Shop using the run-erewhon-shop.ps1 script in the /examples/Erewhon/ folder.
  • You can display logs from both containers, including events written to the jommsg log and the windows event log. To do this, from a PowerShell, run:
docker compose logs