Moved image building from docker-compose to startup script.

This commit is contained in:
yohan 2020-02-26 17:43:43 +01:00
parent e850b73902
commit e4ca53ae54
4 changed files with 32 additions and 4 deletions

View File

@ -4,7 +4,7 @@ services:
openvpn-server: openvpn-server:
image: openvpn-server:$VERSION_OPENVPN_SERVER image: openvpn-server:$VERSION_OPENVPN_SERVER
build: "https://git.scimetis.net/yohan/docker-OpenVPN-server.git" #build: "https://git.scimetis.net/yohan/docker-OpenVPN-server.git"
ports: ports:
- 1194:1194/udp - 1194:1194/udp
volumes: volumes:

22
down.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
sudo docker-compose kill -s SIGTERM
COUNT=1
ATTEMPT=0
while [ $COUNT -ne 0 ] && [ $ATTEMPT -lt 10 ]
do
sleep 1
COUNT=$(sudo docker-compose top | wc -l)
ATTEMPT=$(( $ATTEMPT + 1 ))
done
if [ $COUNT -eq 0 ]
then
sudo docker-compose down
exit 0
else
echo "ERROR: Some containers are still running"
sudo docker-compose ps
exit 1
fi

View File

@ -19,6 +19,12 @@ sudo chown -R root. conf server.conf
# --force-recreate is used to recreate container when crontab file has changed # --force-recreate is used to recreate container when crontab file has changed
unset VERSION_OPENVPN_SERVER unset VERSION_OPENVPN_SERVER
VERSION_OPENVPN_SERVER=$(git ls-remote https://${GIT_SERVER}/yohan/docker-OpenVPN-server.git| head -1 | cut -f 1|cut -c -10) \ export VERSION_OPENVPN_SERVER=$(git ls-remote https://${GIT_SERVER}/yohan/docker-OpenVPN-server.git| head -1 | cut -f 1|cut -c -10)
sudo -E bash -c 'docker-compose up -d --force-recreate'
mkdir -p ~/build
git clone https://git.scimetis.net/yohan/docker-OpenVPN-server.git ~/build/docker-OpenVPN-server
sudo docker build -t openvpn-server:$VERSION_OPENVPN_SERVER ~/build/docker-OpenVPN-server
sudo -E bash -c 'docker-compose up -d --force-recreate'
rm -rf ~/build

View File

@ -13,7 +13,7 @@ done
if [ $COUNT -eq 0 ] if [ $COUNT -eq 0 ]
then then
sudo docker-compose down sudo docker-compose stop
exit 0 exit 0
else else
echo "ERROR: Some containers are still running" echo "ERROR: Some containers are still running"