#!/bin/sh
echo "Welcome!"

version="1.0.1"
oldver="1.0.0"

echo "Pull docker image cdn-admin-frontend:$version from registry."
docker pull alpine-nexus:8500/cdn/cdn-admin-frontend:$version

echo "Stop old container."
docker stop cdn-admin-frontend && docker rm cdn-admin-frontend

echo "Run new container."
docker run -d --name cdn-admin-frontend --restart=always -p 5010:80 alpine-nexus:8500/cdn/cdn-admin-frontend:$version

echo "Remove old image cdn-admin-frontend:$oldver."
docker rmi alpine-nexus:8500/cdn/cdn-admin-frontend:$oldver

echo "Get container logs:"
docker logs cdn-admin-frontend

echo "DONE!"