Skip to content

Setting up your own local CAE instance [Docker]

Philipp edited this page Nov 14, 2020 · 8 revisions

Note: This wiki page is still work in progress.

Important: This setup guide for a local CAE instance is written in the perspective of a windows user. If you are using a different OS, then some things might be a little different for you. Please also note, that some commands contain "^" as a "line-break" which allows for better readability. If you just copy and paste the command, then it will not work. But when you create a .cmd file and copy the command to that file, then running the .cmd file works!

Version information: The CAE setup as described here already contains the project management functionalities and the versioning system. These updates are currently not yet merged into the master-branches of the corresponding repositories. You can find them in the ba-philipp branches. You may need to change the used images from DockerHub in the commands so that you can use the ba-philipp branch.

Overview

The full CAE consists of the following docker images:

In the following, we want to describe how you can start these containers for local development. Note: You could also try to start a local kubernetes cluster with minikube, but for me the setup without minikube worked much better.

y-websockets-service

Needed for Yjs which is used by the CAE-Frontend for the shared modeling. You can start the container with the following command:

docker run --name "yjs" -p 1234:1234 rwthacis/y-websockets-server

After that Yjs is accessible at http://localhost:1234. Note: You will not see anything when you open the page in a web browser. To enable logging, you can add -e DEBUG="y*,-y:connector-message" to the command. Fore more information on logging, see y-websockets-server.

mysql

For persisting models the CAE uses a MySQL database. You can start the container with the following command:

docker run --name "mysql" -p 3306:3306 -e MYSQL_ROOT_PASSWORD="<password>" -e MYSQL_DATABASE="commedit" mysql --character-set-server=utf8mb4 --character_set_filesystem=utf8 --collation-server=utf8mb4_unicode_ci --init-connect="SET NAMES utf8" --init_connect="SET collation_connection = utf8_general_ci" --skip-character-set-client-handshake --default-authentication-plugin=mysql_native_password

Note, that you have to select a password and replace the placeholder with it. After running the command, the MySQL database should be available at http://localhost:3306.

cae-jenkins

Jenkins is used when a Web application developed with the CAE should be deployed. It consists of two jobs. The "Build-Job" loads the content of the temporary deployment repository and builds the las2peer microservices. The "Docker-Job" then starts a docker container by using the cae-deployment docker image.

To start a local Jenkins instance, you can use the following command:

docker run --name "jenkins"^
           -v //var/run/docker.sock:/var/run/docker.sock^
           -p 8093:8083^
           -p 8092:8082^
           -p 8098:8088^
           -p 8097:8087^
           -e JENKINS_URL="http://localhost:8082"^
           -e TEMP_DEPLOYMENT_REPO="https://github.com/<Org>/CAE-Deployment-Temp"^
           -e DEPLOYMENT_URL="http://localhost:8087"^
           -e HOST_IP="127.0.0.1"^
           -e JENKINS_OPTS="--httpPort=8082"^
           rwthacis/cae-jenkins

You need to replace "<Org>" with the name of the GitHub organization where your CAE-Deployment-Temp repository is hosted. For more information see this.

Our Jenkins is running on port 8082 (inside the docker container), but you can access it via http://localhost:8092. Visit this site for an initial setup. Enter the initial admin password, you can get this when the container is starting (from the log) or by reading out the content of the file /var/jenkins_home/secrets/initialAdminPassword (in the docker container). After entering the password, select "Select plugins to install", then "None" and "Install". After that, click "Skip and continue as admin". Then you can click on "Save and Finish". Now you should see both the Build-Job as well as the Docker-Job.

Now, enable "Allow anonymous read access" under Manage Jenkins > Configure Global Security > Authorization.

Once you've done that, we need to do some minor changes to the Docker-Job. Therefore open the config of the Docker-Job by clicking on the Docker-Job first, then click on "Configure" on the left. Under "Build" you can find the shell command which gets executed. Edit the "docker run" command as follows:

  • Link the container with the Jenkins container by adding "--link jenkins:jenkins".
  • Change the environment variable JENKINS_URL from "-e JENKINS_URL=$JENKINS_URL" to "-e JENKINS_URL=jenkins:8082".

Without these changes the local cae-deployment container (which we will setup later) will not be able to find and access Jenkins.

cae-code-generation-service

The Code Generation Service is used for the generation of the source code for the Web application components (and the mashup). You can start the container with the following command:

docker run --name "code-gen-service"^
           --link jenkins:jenkins^
           -e WIDGET_HOME_BASE_URL=https://<GitOrgName>.github.io/^
           -e HTTP_PORT="8080"^
           -e HTTPS_PORT="8443"^
           -e LAS2PEER_PORT="9011"^
           -e SERVICE_PASSPHRASE="someNewPass"^
           -e GIT_USER="<GitUsername>"^
           -e GIT_PASSWORD="<GitPassword>"^
           -e TOKEN="<PersonalAccessToken>"^
           -e GIT_USER_MAIL="<GitMail>"^
           -e GIT_ORGANIZATION="<GitOrgName>"^
           -e TEMPLATE_REPOSITORY="CAE-Templates"^
           -e DEPLOYMENT_REPO="CAE-Deployment-Temp"^
           -e JENKINS_URL=http://jenkins:8082/^
           -e JENKINS_JOB_TOKEN="<JenkinsToken>"^
           -e BUILD_JOB_NAME="Build-Job"^
           -e DOCKER_JOB_NAME="Docker-Job"^
           -p 8080:8080 -p 8443:8443 -p 9011:9011^
           rwthacis/cae-code-generation-service

Note: Switch to the ba-philipp branch.

There are several placeholders here, that you have to edit. The "<GitUsername>" and "<GitPassword>" should belong to a GitHub account which will be used to create new commits. Therefore, also a "<GitUserMail>" is required, which will be used for the commits. Then the "<GitOrgName>" must be the name of a GitHub organization which will be used to store the source code of the components. The "<PersonalAccessToken>" should be a personal access token from a GitHub user account, which also has access to create new repositories in the git organization. The "<JenkinsToken>" is used to trigger Jenkins job during deployment. It needs to be set to the value which can be found in Jenkins under "Build-Job" -> "Configure" -> "Build Triggers" -> "Authentication Token".

The GitHub organization should contain a repository named "CAE-Templates" which can be forked from rwth-acis/CAE-Templates. Besides that the organization needs a repository named "CAE-Deployment-Temp" which will be used to store the applications source code before the deployment process starts. It is important that you initialize the CAE-Deployment-Temp repository, e.g. by creating a first commit.

cae-model-persistence-service

The Model Persistence Service is used to store models and their different versions (used by the versioning system). To start the container, just run the following command:

docker run --name "persistence-service"^
           --link code-gen-service:code-gen-service^
           --link mysql:mysql^
           -p 8081:8081 -p 8444:8444 -p 9012:9012^
           -e HTTP_PORT="8081"^
           -e HTTPS_PORT="8444"^
           -e LAS2PEER_PORT="9012"^
           -e SERVICE_PASSPHRASE="someNewPass"^
           -e MYSQL_USER="root"^
           -e MYSQL_PASSWORD="<DBPassword>"^
           -e MYSQL_HOST=mysql^
           -e MYSQL_PORT="3306"^
           -e MYSQL_DATABASE="commedit"^
           -e DEPLOYMENT_URL="http://localhost:8081"^
           -e BOOTSTRAP="code-gen-service:9011"^
           -e CROSS_ORIGIN_RESSOURCE_DOMAIN="*"^
           -e INIT_WIREFRAME_EXTENSION="true"^
           rwthacis/cae-model-persistence-service

Here you need to edit "<DBPassword>" only. It needs to be the same one which you have set for your MySQL database when starting the MySQL container. Note: Switch to the ba-philipp branch.

cae-project-management-service

The Project Management Service is used to store CAE projects, their connections to the components which they include and the users who should have access to the projects. You can start the container with:

docker run --name "project-management"^
           --link mysql:mysql^
           --link persistence-service:persistence-service^
           -p 8085:8082 -p 9013:9013^
           -e HTTP_PORT="8082"^
           -e HTTPS_PORT="8444"^
           -e LAS2PEER_PORT="9013"^
           -e SERVICE_PASSPHRASE="someNewPass"^
           -e MYSQL_USER="root"^
           -e MYSQL_PASSWORD="<DBPassword>"^
           -e MYSQL_HOST=mysql^
           -e MYSQL_PORT=3306^
           -e GITHUB_PERSONAL_ACCESS_TOKEN=<OrgUserPersonalAccessToken>^
           -e GITHUB_ORGANIZATION=<GitOrgName>^
           -e GITHUB_OAUTH_CLIENTID=<GitHubOAuthClientID>^
           -e GITHUB_OAUTH_CLIENTSECRET=<GitHubOAuthClientSecret>^
           -e BOOTSTRAP=persistence-service:9012^
           -e DISABLE_CATEGORY_CREATION=true^
           rwthacis/cae-project-management-service

Here you need to edit "<DBPassword>" again. The GitHub data used here is only used for the GitHub projects that are created for each CAE project. Thus, the information could be from a different account than the one entered in the Code Generation Service. But you can also use one organization for both. For more information, on how to set the other variables, see the README of rwth-acis/CAE-Project-Management-Service. Note: Switch to the ba-philipp branch.

It is highly recommended to set "DISABLE_CATEGORY_CREATION" to true, because otherwise for all the test projects that you create during the development, categories in the Requirements Bazaar are created automatically (which are not really required if you do not work on the Requirements Bazaar connection).

cae-frontend

The CAE frontend can be started with:

docker run --name cae-frontend^
           -e GIT_ORGANIZATION="<GitOrgName>"^
           -e GITHUB_OAUTH_CLIENTID="<GitHubOAuthClientID>"^
           -e DEPLOYMENT_URL="http://localhost:8087"^
           -e WEBHOST="http://localhost:8070"^
           -e YJS="http://localhost:1234"^
           -e CODEGEN="http://localhost:8080/CodeGen"^
           -e CAE_BACKEND_URL="http://localhost:8081"^
           -e CODE_EDITOR_BOWER="http://localhost:8070/cae-frontend/liveCodeEditorWidget/bower_components/"^
           -e OIDC_CLIENT_ID="<OIDC_CLIENT_ID>"^
           -p 8070:8070^
           rwthacis/cae-frontend

"<GitOrgName>" should be the name of your GitHub organization where the source code of the components is stored. It is used to link the CAE commits to the commits on GitHub. For information on the other variables see rwth-acis/CAE-Frontend. Note: Switch to the ba-philipp branch.