run.sh 1.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
mode="dev"
docker="false"

#
# Run Script for AURA Engine Clock
#
# Call with one of these parameters:
#
# - dev
# - build
David Trattnig's avatar
David Trattnig committed
12
#
13
14
15
16
17
# - docker:dev
# - docker:prod
# - docker:build
# - docker:push
#
18

19
if [[ $* =~ ^(dev|prod|build|push)$ ]]; then
David Trattnig's avatar
David Trattnig committed
20
	mode=$1
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
fi

if [[ "$1" == *"docker:"* ]]; then
	docker="true"
	mode=${1#*:}
fi


echo "[ Run mode=$mode ]"
echo "[ Docker=$docker ]"



# +++ DEFAULT COMMANDS +++ #

if [[ $docker == "false" ]]; then

	### Runs the development server ###

	if [[ $mode == "dev" ]]; then
		npm run dev
	fi

	### Builds a package for production ###

	if [[ $mode == "build" ]]; then
        npm run build
	fi

fi


# +++ DOCKER COMMANDS +++ #

if [[ $docker == "true" ]]; then
David Trattnig's avatar
David Trattnig committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
	BASE_DIR=$(readlink -f .)
	echo "Absolute base dir: " $BASE_DIR

	### Start local development server ###

	if [[ $mode == "dev" ]]; then
		#TODO docker run command for dev server (See dev stage in Dockerfile)
		echo "Missing implementation"
	fi

	### Create build for use in production ###

	if [[ $mode == "prod" ]]; then
		#TODO docker run command for prod build (See prod stage in Dockerfile)
		echo "Missing implementation"
	fi

	### Create Docker Image from local project ###
74

David Trattnig's avatar
David Trattnig committed
75
	if [[ $mode == "build" ]]; then
76
		docker build -t autoradio/dashboard-clock .
David Trattnig's avatar
David Trattnig committed
77
78
79
80
81
	fi

	### Pushes the latest Docker Image to Docker Hub ###

	if [[ $mode == "push" ]]; then
82
		docker push autoradio/dashboard-clock
David Trattnig's avatar
David Trattnig committed
83
	fi
84
fi