Deployment
Content
- 0. Clone Git Repository
- 1. Setup Infrastructure On Azure - Part 1 (Azure Container Registry)
- 2. Set Environment Variables - Part 1
- 3. Use act To Build And Deploy The Container - Part 1 (Initially)
- 4. Setup Infrastructure On Azure - Part 2 (Azure App Service / Database)
- 5. Set Environment Variables - Part 2
- 6. Use act To Build And Deploy The Container - Part 2 (Deploy and restart)
- 7. Set Up Environment Variables On GitHub (Optional)
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:
latestOr 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.
- Unpack the
1. Setup Infrastructure On Azure - Part 1 (Azure Container Registry)
- Set up Azure Container Registry
- Set up an Azure Container Registry. For example the name is
testregistry
. - Set up the desired
Resource Group
(e.g.amos-ws-21-22
). - Get the login data in your created registry under:
Settings
>Access keys
. - Enable
Admin Username
. - Save the credentials for
Registry name
(e.g.testregistry
),Login server
(e.g.testregistry.azurecr.io
),Username
(e.g.testregistry
) andPassword
(e.g.password1234
). - The username and password is to login into the ACR.
- Settings > Access key.
- Set up an Azure Container Registry. For example the name is
2. Set Environment Variables - Part 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 name | Description | ACR Name | Example |
---|---|---|---|
ACR_URL | Name of Azure Container Registry | Login server | testregistry.azurecr.io |
DOCKER_USERNAME | Username for Azure Container Registry | Username | testregistry |
ACR_PW | Password for Azure Container Registry | Password | password1234 |
3. Use act
To Build And Deploy The Container - Part 1 (Initially)
- Install act.
- 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)
- Set up Azure App Service
- Basics
- Set up an Azure App Service.
- Select the desired
Resource Group
(e.g.amos-ws-21-22
). - Set the
Name
of the instance (e.g.similarity-detector
). - Select under
Publish
Docker Container
. - Use
Linux
asOperating System
. - Set up the other required settings.
- Click on the
Next: Docker >
button.
- Docker
- Select as
Image Source
Azure Container Registry
. - Under
Registry
select the previously created registry (e.g.testregistry
). - Select the right
Image
(e.g.similaritydetectordocker/mendixdocker
). - Select the right
Tag
(e.g.dev
).
- Select as
- Basics
- Set up database
- Set up database named
mendix
(for example on Azure)
- Set up database named
- Set up environment variables on Azure
- Go to the previously created App Service (
similarity-detector
). - Go to
Settings
>Configuration
>Application Settings
. - Add the following environment variables (For Mendix login):
- Go to the previously created App Service (
Variable name | Description | Example |
---|---|---|
ADMIN_PASSWORD | Password for the Mendix website login | |
DATABASE_ENDPOINT | Connection string for database | postgres://... |
WEBSITES_PORT | Port for Mendix frontend | 8080 |
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 name | Description | Example |
---|---|---|
AZURE_CREDENTIALS | Credentials for Azure | {"clientId": "...", "clientSecret: "..." ...} |
AZURE_APP_SERVICE_NAME | Name of the Azure WebApp | similarity-detector |
AZURE_APP_SERVICE_RESOURCE_GROUP | Name of the Azure Resource Group | amos-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 |