#!/bin/sh

set -e

echo "readonly" | docker login docker.med-logic.ru --username readonly --password-stdin
docker pull docker.med-logic.ru/medicine:latest

(cd /root/medicine-config/medicine &&
  docker-compose stop &&
  docker-compose up -d
)

(cd /root/medicine-config/medicine && docker-compose run --rm app python manage.py post_update)

docker rmi $(docker images -f "dangling=true" -q)
