[Unit] Description=sends links to telegram from whatsapp chats and email Requires=docker.service After=docker.service [Service] Restart=always # Set working directory to where you've cloned the project WorkingDirectory=/home/user/Meetings-Channel # There can be random links it misses if it runs for too long, so restart every 12 hours RuntimeMaxSec=43200 # Remove old containers, images and volumes ExecStartPre=/usr/local/bin/docker-compose down -v ExecStartPre=/usr/local/bin/docker-compose rm -fv ExecStartPre=-/bin/bash -c 'docker volume ls -qf "name=%i_" | xargs docker volume rm' ExecStartPre=-/bin/bash -c 'docker network ls -qf "name=%i_" | xargs docker network rm' ExecStartPre=-/bin/bash -c 'docker ps -aqf "name=%i_*" | xargs docker rm' # build the docker image ExecStartPre=/usr/bin/docker build -t meetings-channel . # Compose up ExecStart=/usr/local/bin/docker-compose up --remove-orphans --abort-on-container-exit # Compose down, remove containers, untagged images and volumes ExecStop=/usr/local/bin/docker-compose down -v --remove-orphans ExecStop=/usr/bin/docker rmi f_whatsapp_whatsapp:latest -f ExecStop=/usr/bin/docker image prune -f [Install] WantedBy=multi-user.target