-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleweb.start
More file actions
executable file
·60 lines (49 loc) · 2.38 KB
/
simpleweb.start
File metadata and controls
executable file
·60 lines (49 loc) · 2.38 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
#!/bin/bash
# Simple website which shows the IP of visitor. Very useful for testing Traefik configuration etc
# Update GitHub with any changes to Docker scripts (timeout to default No after 10s).
read -r -n 10 -t 5 -p "`echo -e $'\e[0;35m'`Do you wish to update git repo for docker run scripts? [y/N] `echo -e $'\n\e[1;35m'`(Script will continue without updating repo if no response in 5s)`echo -e $'\e[0m'`" response
response=${response:-No} # Default response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
/home/ryan/scripts/docker/_update_git.sh
fi
echo
# Get sensitive info from .conf file
CONF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
typeset -A secrets # Define array to hold variables
while read line; do
if echo $line | grep -F = &>/dev/null; then
varname=$(echo "$line" | cut -d '=' -f 1); secrets[$varname]=$(echo "$line" | cut -d '=' -f 2-)
fi
done < $CONF_DIR/simpleweb.conf
#echo ${secrets[FQDN]}; echo ${secrets[USERNAME]}; echo ${secrets[PASSWORD]}
FQDN="${secrets[FQDN]}"
NAME="simpleweb"
docker stop $NAME
docker rm -f -v $NAME
# Since we can't assign two networks with 'docker run' we need to create the container first,
# then add to traefik-proxy network and default bridge network before starting it.
#docker run -d \
docker create \
--restart="unless-stopped" \
--name=$NAME \
`# Can still access via 192.168.0.10:81 by mapping port i.e. dont need to use proxied route` \
-p 81:80 \
`# ------- Traefik Proxy Section -------` \
--network traefik-proxy \
-l "traefik.enable=true" \
-l "traefik.port=80" \
`###### To access container on home.$FQDN/$NAME` \
`#-l "traefik.frontend.rule=Host:home.$FQDN;PathPrefixStrip:/$NAME"` \
`###### Or uncomment to access container on $NAME.$FQDN` \
-l "traefik.frontend.rule=Host:$NAME.$FQDN" \
`###### Username/password pulled from conf file with code at top of script ` \
-l "traefik.frontend.auth.basic.users=${secrets[USERNAME]}:${secrets[PASSWORD]}" \
`###### Username/password defined in file in Traefik volume` \
`#-l "traefik.frontend.auth.basic.usersFile=/etc/traefik/htpasswds/htpasswd_simpleweb"` \
`# -------------------------------------` \
yeasy/simple-web:latest
# Add to bridge & traefik-proxy network so it can reach the other container
docker network connect bridge $NAME
docker network connect traefik-proxy $NAME
# Start container
docker start $NAME