This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathbuild
executable file
·81 lines (58 loc) · 1.92 KB
/
build
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
# Copyright (c) Microsoft. All rights reserved.
# Note: Windows Bash doesn't support shebang extra params
set -e
# Note: use lowercase names for the Docker images
DOCKER_IMAGE="azureiotpcs/device-simulation-dotnet"
# "testing" is the latest dev build, usually matching the code in the "master" branch
DOCKER_TAG="$DOCKER_IMAGE:testing"
# Debug|Release
CONFIGURATION=Release
APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"
cleanup_tmp_files() {
check_dependency_dotnet
cd $APP_HOME
header "Removing temporary folders and files..."
rm -fR packages
rm -fR target
rm -fR out
PROJECTS=$(dotnet sln list | grep 'csproj$')
for PROJ in $PROJECTS; do
PROJ=$(dirname "$PROJ")
cd $PROJ
rm -fR bin/
rm -fR obj/
cd $APP_HOME
done
echo -e "\nDone"
}
compile() {
check_dependency_dotnet
cd $APP_HOME
dotnet restore
dotnet build --configuration $CONFIGURATION
}
build_docker_image() {
check_dependency_docker
check_dependency_git
cd $APP_HOME
DOCKER_LABEL2="Commit=$(git log --pretty=format:'%H' -n 1)"
DOCKER_LABEL3="Date=$(/usr/bin/env date +%Y-%m-%dT%H:%M:%S)"
rm -fR out/docker
rm -fR WebService/bin/Docker
mkdir -p out/docker/webservice
dotnet publish WebService --configuration $CONFIGURATION --output bin/Docker
cp -pR WebService/bin/Docker/* out/docker/webservice/
cp scripts/docker/.dockerignore out/docker/
cp scripts/docker/Dockerfile out/docker/
cp scripts/docker/content/run.sh out/docker/
cd out/docker/
docker build --compress --tag $DOCKER_TAG \
--label "$DOCKER_LABEL2" --label "$DOCKER_LABEL3" .
echo "Run './scripts/docker/publish' to publish the image to the registry"
}
cleanup_tmp_files
compile
build_docker_image
set +e