run.sh 1.3 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

David Trattnig's avatar
David Trattnig committed
14
if [[ $* =~ ^(dev|build|push)$ ]]; then
David Trattnig's avatar
David Trattnig committed
15
	mode=$1
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
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	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 ###
69

David Trattnig's avatar
David Trattnig committed
70
71
72
73
74
75
76
77
78
	if [[ $mode == "build" ]]; then
		docker build -t autoradio/engine-clock .
	fi

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

	if [[ $mode == "push" ]]; then
		docker push autoradio/engine-clock
	fi
79
fi