File tree Expand file tree Collapse file tree 5 files changed +113
-0
lines changed
Expand file tree Collapse file tree 5 files changed +113
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,48 @@ docker logs fsmgmt
2525```
2626
2727## Deploy it to the production
28+ The infrastructure is implemented with terraform and all the configs and scripts exists under ` infra/ ` directory
29+
30+ ### Prerequisites:
31+ 1 . ` terraform ` installed and available on the path
32+ 2 . ` az ` cli installed and ready to be logged in
33+
34+ ### Setup the environment
35+ 1 . Setup python ` fsmgmt ` venv environment
36+ ```
37+ python -m venv fsmgmt
38+ source fsmgmt/bin/activate
39+ ```
40+ 2 . Setup subscription and credentials
41+ a. Change directory to the correct directory
42+ ```
43+ cd infra/
44+ ```
45+ b. Store ` .env.template ` to ` .env ` and values to it.
46+ ```
47+ cp .env.template .env
48+ # Edit .env and fill-in values
49+ ```
50+ c. Source those values with ` source ` command
51+ ```
52+ source .env
53+ ```
54+ d. Login to your Azure subscription with az cli to provide access to terraform
55+ ```
56+ az login
57+ ```
58+
59+ ### Perform the infra creation
60+
61+ 1 . Terraform initialize
62+ ```
63+ terraform init
64+ ```
65+ 2 . Terraform apply
66+ ```
67+ terraform apply
68+ ```
69+
2870
2971
3072## Plan
Original file line number Diff line number Diff line change 1+ # Bash shell users uncomment and use this:
2+ # export ARM_SUBSCRIPTION_ID=<PLACE VALUE HERE>
3+ # export ARM_TENANT_ID=<PLACE VALUE HERE>
4+
5+ # Fish shell users uncomment and use this:
6+ # set -gx ARM_SUBSCRIPTION_ID <PLACE VALUE HERE>
7+ # set -gx ARM_TENANT_ID <PLACE VALUE HERE>
Original file line number Diff line number Diff line change 1+ # Fetch the existing resource group
2+ data "azurerm_resource_group" "fsmgmt" {
3+ name = var. rg_name
4+ }
5+
6+ # Container registry to store the images, public for now
7+ resource "azurerm_container_registry" "fsmgmt" {
8+ name = var. app_name
9+ resource_group_name = data. azurerm_resource_group . fsmgmt . name
10+ location = data. azurerm_resource_group . fsmgmt . location
11+ sku = " Standard"
12+ admin_enabled = true
13+ }
14+
15+ # Service plan for the app service
16+ resource "azurerm_service_plan" "fsmgmt" {
17+ name = var. app_name
18+ resource_group_name = data. azurerm_resource_group . fsmgmt . name
19+ location = data. azurerm_resource_group . fsmgmt . location
20+ os_type = " Linux"
21+ sku_name = " P1v2"
22+ }
23+
24+ # The app itself, pulling image from ACR
25+ resource "azurerm_linux_web_app" "fsmgmt" {
26+ name = var. app_name
27+ resource_group_name = data. azurerm_resource_group . fsmgmt . name
28+ location = azurerm_service_plan. fsmgmt . location
29+ service_plan_id = azurerm_service_plan. fsmgmt . id
30+
31+ site_config {
32+ application_stack {
33+ docker_image_name = var. app_name
34+ docker_registry_url = " https://${ azurerm_container_registry . fsmgmt . login_server } "
35+ docker_registry_username = azurerm_container_registry. fsmgmt . admin_username
36+ docker_registry_password = azurerm_container_registry. fsmgmt . admin_password
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ azurerm = {
4+ source = " hashicorp/azurerm"
5+ version = " 4.14.0"
6+ }
7+ }
8+ }
9+
10+ provider "azurerm" {
11+ features {
12+
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ # Default values for variables
2+
3+ variable "app_name" {
4+ default = " fsmgmt"
5+ type = string
6+ }
7+
8+ variable "rg_name" {
9+ default = " fsmgmt-tmp"
10+ type = string
11+ }
You can’t perform that action at this time.
0 commit comments