-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·51 lines (37 loc) · 1.82 KB
/
script.sh
File metadata and controls
executable file
·51 lines (37 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
####################################################################################
#DISCLAIMER
#This script should only be used for testing and NOT for any kind of production environment. There has been no focus on any subject regarding security, redundancy or reliability!
#Strobodov - 2019 - @AT Computing
####################################################################################
#read variables from config file.
source config/variables
# read Azure username & password to log in
# !!! Make sure this file does NOT get public !!!
# you should consider using a Service Principal instead of a user account...
#
source config/cred
#login to Azure using AZ CLI
az login -u $azure -p $azure_password
#define name of the resource group and Azure region you want to deploy in. (see Azure documentation for current list of options)
az group create -n $group_name --location $az_location
#deploy VM in Azure. Make sure you have filled out all key value paires in config/variables
az vm create --name $vm_name --resource-group $group_name --admin-username $admin --generate-ssh-keys --image ubuntults --verbose --public-ip-address-dns-name $dns_name --size Standard_D2_v3
#publish port 80 to the outside world (to make sure your webapp can be reached via http)
az vm open-port --resource-group $group_name --name $vm_name --port 80
#log into the Ubuntu VM in Azure
ssh "$admin"@"$fqdn" -o StrictHostKeyChecking=no -o IdentitiesOnly=yes <<EOF
#update package list
sudo apt update
#install docker
sudo apt-get install docker.io --assume-yes
#clone the webapp git repo from github
git clone https://github.com/Strobodov/App.git
#change directory
cd App
#build the docker container
sudo docker build docker --tag=mywebapp
#run the container
sudo docker run -d -p 80:80 mywebapp
EOF
printf "\rOpen your browser and open %s\n" "$fqdn"