Deployment


Content


To deploy the infrastructure and code follow the following steps:

For the initial setup use Steps 0. (Clone Git Repository) - 7. (Set Up Environment Variables On GitHub Optional). These Steps must be executed only once at the beginning.

If it has already been deployed initially, proceed to step 6. Use act To Build And Deploy The Container - Part 2 (Deploy and restart).

0. Clone Git Repository

# SSH
git clone git@github.com:Re-Krass/amos2021ws06-exp-similarity-detector-frontend.git
# HTTPS
git clone git clone https://github.com/Re-Krass/gitamos2021ws06-exp-similarity-detector.git

  • Or download the latest release and unzip the package from:
    latest

  • Or you can also download the Amos_Project_6_Exp_Similarity_Detector.mpk file directly from the latest release.

    • Unpack the Amos_Project_6_Exp_Similarity_Detector.mpk file an empty folder.

1. Setup Infrastructure On Azure - Part 1 (Azure Container Registry)

  1. Set up Azure Container Registry
    1. Set up an Azure Container Registry. For example the name is testregistry.
    2. Set up the desired Resource Group (e.g. amos-ws-21-22).
    3. Get the login data in your created registry under: Settings > Access keys.
    4. Enable Admin Username.
    5. Save the credentials for Registry name (e.g. testregistry), Login server (e.g. testregistry.azurecr.io), Username (e.g. testregistry) and Password (e.g. password1234).
    6. The username and password is to login into the ACR.
    7. Settings > Access key.

2. Set Environment Variables - Part 1

  1. Copy the file template.secrets to a file named .secrets and replace "<Please set this variable>" with the right variables. See table below.
Variable nameDescriptionACR NameExample
ACR_URLName of Azure Container RegistryLogin servertestregistry.azurecr.io
DOCKER_USERNAMEUsername for Azure Container RegistryUsernametestregistry
ACR_PWPassword for Azure Container RegistryPasswordpassword1234

3. Use act To Build And Deploy The Container - Part 1 (Initially)

  1. Install act.
  2. Execute command (from the amos2021ws06-exp-similarity-detector-frontend directory):
    act --secret-file .secrets -j build_and_deploy_initial

4. Setup Infrastructure On Azure - Part 2 (Azure App Service / Database)

  1. Set up Azure App Service
    1. Basics
      1. Set up an Azure App Service.
      2. Select the desired Resource Group (e.g. amos-ws-21-22).
      3. Set the Name of the instance (e.g. similarity-detector).
      4. Select under Publish Docker Container.
      5. Use Linux as Operating System.
      6. Set up the other required settings.
      7. Click on the Next: Docker > button.
    2. Docker
      1. Select as Image Source Azure Container Registry.
      2. Under Registry select the previously created registry (e.g. testregistry).
      3. Select the right Image (e.g. similaritydetectordocker/mendixdocker).
      4. Select the right Tag (e.g. dev).
  2. Set up database
    1. Set up database named mendix (for example on Azure)
  3. Set up environment variables on Azure
    1. Go to the previously created App Service (similarity-detector).
    2. Go to Settings > Configuration > Application Settings.
    3. Add the following environment variables (For Mendix login):
Variable nameDescriptionExample
ADMIN_PASSWORDPassword for the Mendix website login
DATABASE_ENDPOINTConnection string for databasepostgres://...
WEBSITES_PORTPort for Mendix frontend8080

5. Set Environment Variables - Part 2

Go to the .secrets and replace the missing variables values "<Please set this variable>" with the right variables values.

Variable nameDescriptionExample
AZURE_CREDENTIALSCredentials for Azure{"clientId": "...", "clientSecret: "..." ...}
AZURE_APP_SERVICE_NAMEName of the Azure WebAppsimilarity-detector
AZURE_APP_SERVICE_RESOURCE_GROUPName of the Azure Resource Groupamos-ws-21-22

To get the AZURE_CREDENTIALS fill out the variables in the script create_credentials.sh (.github/workflows/create_credentials.sh) and execute it. Copy and paste the output in the AZURE_CREDENTIALS secret variable on GitHub or copy it in a single line for local execution.

6. Use act To Build And Deploy The Container - Part 2 (Deploy and restart)

Execute command (from the amos2021ws06-exp-similarity-detector-frontend directory):
act --secret-file .secrets -j build_and_deploy

7. Set Up Environment Variables On GitHub (Optional)

Set these variables in the Secrets section on GitHub if you like to use GitHub Actions CI to build and deploy the website.
For descriptions see the sections above.

Variable name
ACR_URL
DOCKER_USERNAME
ACR_PW
AZURE_CREDENTIALS
AZURE_APP_SERVICE_NAME
AZURE_APP_SERVICE_RESOURCE_GROUP