Add upgrade procedure with remove/deploy

This commit is contained in:
Benoit S 2021-09-27 21:38:10 +09:00
parent 35633ef865
commit ba318533e9
4 changed files with 32 additions and 5 deletions

View File

@ -15,6 +15,15 @@ Pyinfra that deploy PhotoPrism un-dockerized on a Debian 11 LXD container.
# pyinfra inventories/production.py deploy.py
```
## Upgrade
Run `remove.py` then `deploy.py`.
```
# pyinfra inventories/production.py remove.py
# pyinfra inventories/production.py deploy.py
```
# Attach a pictures volume
If required, you can mount external volumes. Example:

View File

@ -88,11 +88,12 @@ files.directory(
mode=755
)
server.shell(
name='Undocker the Docker image',
chdir=host.data.undocker_dst,
commands=['undocker '+host.data.undocker_cache+'/photoprism.tar - | tar -xv'],
)
if not host.fact.directory(host.data.undocker_dst):
server.shell(
name='Undocker the Docker image',
chdir=host.data.undocker_dst,
commands=['undocker '+host.data.undocker_cache+'/photoprism.tar - | tar -xv'],
)
files.template(
name='Set env file',

16
remove.py Normal file
View File

@ -0,0 +1,16 @@
from pyinfra import host
from pyinfra.operations import server, files
if host.fact.file(host.data.undocker_cache+'/photoprism.tar'):
server.shell(
name='Remove photoprism Docker image',
chdir=host.data.undocker_cache,
commands=['rm photoprism.tar'],
)
if host.fact.directory(host.data.undocker_dst):
server.shell(
name='Remove undocker destination',
commands=['rm -rf {}'.format(host.data.undocker_dst)],
)

View File

@ -3,6 +3,7 @@ set -euo pipefail
systemd-run \
--pty \
--unit='photoprism-run' \
--description='photoprism binary call' \
--property=User={{ host.data.unix_user }} \
--property=Group={{ host.data.unix_group }} \