Using Docker 19.03.3, auto-restart webapp

This commit is contained in:
Chai Feng 2020-01-06 13:17:19 +08:00
parent 149e84e8af
commit b7e1f8860e

5
Vagrantfile vendored
View File

@ -5,7 +5,7 @@
Vagrant.configure('2') do |config| Vagrant.configure('2') do |config|
config.vm.box = "chaifeng/ubuntu-18.04-docker-19.03" config.vm.box = "chaifeng/ubuntu-18.04-docker-19.03.3"
config.vm.provider 'virtualbox' do |vb| config.vm.provider 'virtualbox' do |vb|
vb.memory = '1024' vb.memory = '1024'
@ -116,7 +116,7 @@ DOCKERFILE
webapp="${name%:*}_webapp" webapp="${name%:*}_webapp"
port="${name#*:}" port="${name#*:}"
if docker inspect "$webapp" &>/dev/null; then docker stop "$webapp"; fi if docker inspect "$webapp" &>/dev/null; then docker stop "$webapp"; fi
docker run -d --rm --name "$webapp" \ docker run -d --restart unless-stopped --name "$webapp" \
-p "$port:80" --env name="$webapp" #{private_registry}/chaifeng/hostname-webapp -p "$port:80" --env name="$webapp" #{private_registry}/chaifeng/hostname-webapp
sleep 1 sleep 1
done done
@ -159,6 +159,7 @@ DOCKERFILE
external.vm.provision "testing", type: 'shell', inline: <<-SHELL external.vm.provision "testing", type: 'shell', inline: <<-SHELL
set -euo pipefail set -euo pipefail
set -x
server="http://#{ip_prefix}.130" server="http://#{ip_prefix}.130"
function test-webapp() { timeout 3 curl --silent "$@"; } function test-webapp() { timeout 3 curl --silent "$@"; }
test-webapp "$server:8080" test-webapp "$server:8080"