Docker
Docker is a convenient and efficient method to run the Babel Licensing Service for testing purposes. Docker provides a lightweight and isolated environment called a container, which encapsulates the Babel Licensing Service and all its dependencies, making it easy to deploy and test the service on various systems without worrying about compatibility issues or conflicts with the host environment.
Prerequisites
Babel Licensing Service ZIP package (babel_service_net80_10.x.y.zip)
Babel Obfuscator Company License file (babel.licenses)
Before proceeding, it is important to ensure that Docker is installed on your system. Visit the official Docker website and follow the provided installation instructions specific to your operating system. Complete the installation process to have Docker up and running.
Setting up the Babel Licensing Service on Docker is a straightforward process. In this comprehensive guide, we will walk you through the step-by-step instructions to ensure a successful installation.
Create the Dockerfile
To prepare the environment for building the Babel Licensing Service image using Docker, please follow the steps below.
Begin by establishing a folder on your local machine specifically designated for working with the Babel Licensing Service files. We will refer to this folder as "working folder".
Copy the Babel Licensing Service ZIP archive and the babel.licenses file into the working folder created in the previous step.
Extract the contents of the Babel Licensing Service ZIP archive into a subfolder titled "babel" within the working folder.
Within the working folder, create a new file named "Dockerfile." You may utilize a text editor or integrated development environment (IDE) of your preference to generate this file.
Copy the content provided for the Dockerfile below and save it into the newly generated "Dockerfile" file.
Let's break down its contents:
This line specifies the base image for the Docker container. In this case, it is using the ASP.NET runtime image from Microsoft's Container Registry.
The EXPOSE instruction specifies that the container exposes this port to the host machine, allowing external access.
The WORKDIR instruction sets the working directory inside the container to /var/www/svc/babel
. This is the location where subsequent commands will be executed.
This line copies the contents of the babel
directory (containing the Babel Licensing Service files) from the babel working folder directory into the container's working directory /var/www/svc/babel.
Similarly, this line copies the babel.licenses
file from the build context into the container's working directory.
The ENTRYPOINT instruction specifies the command that will be executed when the container starts. In this case, it is running the dotnet
command with the Babel.Licensing.Service.dll
as the entry point for the Babel Licensing Service.
This Dockerfile sets up the necessary environment, exposes the required port, copies the service files and license file, and defines the entry point for the Babel Licensing Service.
Once built using Docker, this image can be used in conjunction with Docker Compose to deploy the Babel Licensing Service.
Docker Compose
So far, we have instructed Docker to build the image that runs the Babel Licensing Service, but we have not instructed the configuration to actually startup any database.
To configure the complete setup for the Babel Licensing Service, including the necessary database, we will create a new file named docker-compose.yml
in the working folder. Add the following content to the docker-compose.yml
file:
The docker-compose.yml
file defines an application with two services: licensing
and db
. The image for the licensing service is built using the specified Dockerfile
.
When deploying the application using Docker Compose, the container port 5005
is mapped to the host port 5005
, as indicated in the file. Please ensure that the port 5005
on the host machine is not being used by another container. If it is, you can modify the port to an available one.
Remember to replace the MySQL root and user passwords with strong and secure passwords (you don't need to remember them) under the db
service and inside the Babel Service Connection string. The user password is used to set up the connection with the MySQL database.
The docker-compose.yml
file is responsible for defining how the Docker images interact with each other at runtime. It specifies the necessary configurations, environment variables, and network setup for the services. By using Docker Compose with this file, you can easily deploy and manage the Babel Licensing Service along with the associated database.
Starting the Service
After setting up the docker-compose.yml
file as described in the previous paragraph, you can proceed to run the command:
This command will start the Babel Licensing Service and the associated database in detached mode. Wait for the containers to start: Docker Compose will start pulling the required images (if not already present) and create the containers based on the configurations specified in the docker-compose.yml
file. It may take a few moments for the containers to be fully up and running.
After running the command, you can use the docker ps
command to verify that the containers are running. It will display a list of running containers along with their details, including the Babel Licensing Service and the associated database container.
Stopping the Service
To stop and remove the containers, as well as delete the associated volumes, you can use the following commands:
Stop and Remove Containers: To stop and remove the containers that were created using Docker Compose, execute the following command:
The down
command halts and removes the containers defined in the docker-compose.yml
file. It stops the running containers and removes their associated resources, such as networks and volumes while preserving the images.
Stop and Delete Volumes: If you also want to delete the volumes associated with the containers, you can use the
-v
flag with thedown
command. Run the following command:
Adding the -v
flag instructs Docker Compose not only to stop and remove the containers but also to delete the volumes that were created during the container lifecycle. This ensures the clean removal of all resources related to the containers including the database data files.
Please note that when executing these commands, it is important to be in the same directory where the docker-compose.yml
file is located. Additionally, make sure you have Docker Compose installed and available in your command-line environment.
By running docker compose down
or docker compose down -v
, you will effectively stop and remove the containers, as well as delete the associated volumes, cleaning up the resources used by the Babel Licensing Service.
Configure Babel Licensing Service
The docker-compose.yml
file allows you to configure the environment for the babel-licensing
service container by specifying several environment variables. These variables override the default configuration settings of the Babel Licensing Service, which are stored in the appsettings.json
file. Here is an expanded description of the available configuration variables:
DOTNET_CLI_HOME
: Specifies the location of the CLI (Command Line Interface) temporary directory for .NET. In this case, it is set to/tmp
.ASPNETCORE_ENVIRONMENT
: Sets the environment for the Babel Licensing Service to run in. The valueProduction
indicates that the service is running in a production environment.KESTREL__ENDPOINTS__GRPC__URL
: Defines the URL for the GRPC endpoint of the Babel Licensing Service. In this case, it is set tohttp://*:5005
, indicating that the service listens on all available network interfaces on port 5005.BABEL_SERVICE_DATABASE__PROVIDER
: Specifies the database provider to be used by the Babel Licensing Service. The valueMySQL
indicates that MySQL will be used as the database provider.BABEL_SERVICE_CONNECTIONSTRINGS__MYSQL
: Sets the connection string for the MySQL database. It specifies the server, user, password, and database name to be used by the Babel Licensing Service.BABEL_SERVICE_APPLICATION__SIGNINGKEY
: Defines the signing key used for generating and validating authentication tokens for the Babel Licensing Service.BABEL_SERVICE_APPLICATION__TOKENEXPIRATION
: Sets the expiration time for authentication tokens issued by the Babel Licensing Service.BABEL_SERVICE_LICENSING__HEARTBEATINTERVAL
: Specifies the maximum interval at which the clients must send heartbeats to the Babel Licensing Service. The format ishh:mm:ss
, indicating the time interval between each heartbeat.BABEL_SERVICE_REPORTING__ENCRYPTIONKEY
: Defines the encryption key used for encrypting data in the reporting functionality of the Babel Licensing Service.
These environment variables allow you to customize and configure various aspects of the Babel Licensing Service according to your specific requirements. By overriding these variables in the docker-compose.yml
file, you can modify the service's behaviour without modifying the original appsettings.json
file, providing flexibility and ease of configuration.
MSSQL Server Docker Image
To configure Babel Licensing with MSSQL in Docker, the setup utilizes the latest Azure SQL Edge image, which is compatible with Linux Ubuntu. The YAML configuration provided outlines key environment variables essential for database access, authentication tokens, and licensing parameters. This approach streamlines the deployment and integration of Babel Licensing with an MSSQL database within a Docker environment.
By using Docker, you can quickly set up an instance of the Babel Licensing Service without having to manually configure and install all the required dependencies on your local machine or server. This means you can avoid potential conflicts with existing software versions or dependencies, streamlining the setup process and saving time.
Last updated