There are several solutions, the first has already indicated mymedia
- ssh user@host 'cd /my/work/path; docker-compose up -d' - ssh user@host 'cd /my/work/path && docker-compose up -d'
Another, but similar approach is to create / create an intermediate management script (for example, run.sh):
# ci # ... variables: SSH_WD: /my/work/path script: - cat docker/prod/run.sh | ssh user@host "cat > ${SSH_WD}/run.sh" - ssh user@host "chmod +x ${SSH_WD}/run.sh" - ssh user@host "${SSH_WD}/run.sh" # ...
and about run.sh
#!/bin/bash -xe # здесь можно использовать "любую" логику # управления перезапуском сервисов или приложения в целом cd /my/work/path docker-compose stop #docker-compose down #docker pull my/image:latest docker-compose up -d exit 0
Yes, it is more difficult, but it opens extra. management capabilities, plus the management script is stored in git.
I generate such files automatically during assembly and deployment, it gives the opportunity to make adjustments, add logic, add hooks or checks, use variables, etc. I will say more that the docker-compose.yml also automatically generated. At first it seemed complicated, but it turned out to be very convenient for the team.