Add upgrade procedure with remove/deploy
This commit is contained in:
parent
35633ef865
commit
ba318533e9
4 changed files with 32 additions and 5 deletions
|
@ -15,6 +15,15 @@ Pyinfra that deploy PhotoPrism un-dockerized on a Debian 11 LXD container.
|
||||||
# pyinfra inventories/production.py deploy.py
|
# 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
|
# Attach a pictures volume
|
||||||
|
|
||||||
If required, you can mount external volumes. Example:
|
If required, you can mount external volumes. Example:
|
||||||
|
|
|
@ -88,11 +88,12 @@ files.directory(
|
||||||
mode=755
|
mode=755
|
||||||
)
|
)
|
||||||
|
|
||||||
server.shell(
|
if not host.fact.directory(host.data.undocker_dst):
|
||||||
|
server.shell(
|
||||||
name='Undocker the Docker image',
|
name='Undocker the Docker image',
|
||||||
chdir=host.data.undocker_dst,
|
chdir=host.data.undocker_dst,
|
||||||
commands=['undocker '+host.data.undocker_cache+'/photoprism.tar - | tar -xv'],
|
commands=['undocker '+host.data.undocker_cache+'/photoprism.tar - | tar -xv'],
|
||||||
)
|
)
|
||||||
|
|
||||||
files.template(
|
files.template(
|
||||||
name='Set env file',
|
name='Set env file',
|
||||||
|
|
16
remove.py
Normal file
16
remove.py
Normal 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)],
|
||||||
|
)
|
||||||
|
|
|
@ -3,6 +3,7 @@ set -euo pipefail
|
||||||
|
|
||||||
systemd-run \
|
systemd-run \
|
||||||
--pty \
|
--pty \
|
||||||
|
--unit='photoprism-run' \
|
||||||
--description='photoprism binary call' \
|
--description='photoprism binary call' \
|
||||||
--property=User={{ host.data.unix_user }} \
|
--property=User={{ host.data.unix_user }} \
|
||||||
--property=Group={{ host.data.unix_group }} \
|
--property=Group={{ host.data.unix_group }} \
|
||||||
|
|
Reference in a new issue