-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakeContainer.sh
More file actions
executable file
·61 lines (42 loc) · 1.46 KB
/
Copy pathmakeContainer.sh
File metadata and controls
executable file
·61 lines (42 loc) · 1.46 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
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
while getopts "g:n:r:p:d" arg; do
case $arg in
g) RES_GROUP=${OPTARG};;
n) REG_NAME=${OPTARG};;
r) GIT_REPO=${OPTARG};;
p) GIT_PAT=${OPTARG};;
d) DELETE=true;;
esac
done
az login
IFS='/' read -ra git_name <<< "$GIT_REPO"
REPO_NAME=$(echo ${git_name[@]: -1} | sed "s/.git//g")
if [ $(az group exists -n $RES_GROUP) = false ] ; then
az group create --name $RES_GROUP --location westus
fi
echo "Creating Registry"
az acr create -g $RES_GROUP -n $REG_NAME --sku Basic
az acr login -n $REG_NAME
echo "Registry Created"
echo "Creating Task"
az acr task create \
--registry $REG_NAME \
--name $REPO_NAME \
--image $REPO_NAME:{{.Run.ID}} \
--context $GIT_REPO \
--file Dockerfile \
--git-access-token $GIT_PAT
LOG_IN="$REG_NAME.azurecr.io"
echo "Now will run task"
az acr task run --registry $REG_NAME --name acrrun
echo "Running at: $LOG_IN"
# Get latest tags of image
# Make web app now which runs image (make this optional)
# Add update web app option
az appservice plan create -g $RES_GROUP -n WebContainerPlan --is-linux
LATEST_TAG=$(az acr repository show-tags -n $REG_NAME --repository $REPO_NAME --top 1 --orderby time_desc)
#Below Example is only for ACR, User will maunally have to enter image for Dockerhub
IMG_NAME="$LOG_IN/REPO_NAME:$LATEST_TAG"
#Make for private DockerHub
az webapp create -g $RES_GROUP -p WebContainerPlan -n ImageApp -i $IMG_NAME
#Implement new deployment when acr repo or dockerhub image is updated