-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·42 lines (35 loc) · 1.13 KB
/
run.sh
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
#!/bin/bash
NETWORK_IP=172.10.10.0/24
NGINX_IP=172.10.10.2
PYTHON_IP=172.10.10.3
NETWORK_NAME=sensehat
PYTHON_HOSTNAME=python
NGINX_CONTAINER=sh-nginx
PYTHON_CONTAINER=sh-python
if [ -z "$(docker network ls -q -f name=$NETWORK_NAME)" ]; then
docker network create \
--subnet $NETWORK_IP \
--opt com.docker.network.bridge.name=$NETWORK_NAME \
--opt com.docker.network.bridge.enable_icc=true \
$NETWORK_NAME
fi
docker stop $PYTHON_CONTAINER && docker rm $PYTHON_CONTAINER
docker run -d \
-v $(pwd)/sensehat_listener.py:/sensehat_listener.py \
-v $(pwd)/dummy_sense_hat.py:/dummy_sense_hat.py \
-v /etc/localtime:/etc/localtime:ro \
--name $PYTHON_CONTAINER \
--net $NETWORK_NAME --ip $PYTHON_IP \
--privileged \
sensehat python3 /sensehat_listener.py -p 80
docker stop $NGINX_CONTAINER && docker rm $NGINX_CONTAINER
docker run -d \
-v $(pwd)/nginx.conf:/etc/nginx/nginx.conf \
-v $(pwd)/webroot:/var/www/html \
-v $(pwd)/openapi.yaml:/var/www/html/openapi.yaml \
-v /etc/localtime:/etc/localtime:ro \
--name $NGINX_CONTAINER \
--add-host=$PYTHON_HOSTNAME:$PYTHON_IP \
--net $NETWORK_NAME --ip $NGINX_IP \
-p 10080:80 \
nginx:1.14.0