deployd/interpreter/examples/ari-lt.deployer
Arija A. fca825f872
Improve deployer exports
Signed-off-by: Arija A. <ari@ari.lt>
2025-07-25 00:32:07 +03:00

80 lines
1.6 KiB
Text
Executable file

#!/usr/bin/env deployer
# --------------------------------------
# Name: ari.lt deploy
# Extensions: python3 credentials daemon
# User: ari
# Group: ari
# Target: /tmp/ari.lt
# --------------------------------------
# All actions logged
# Prepare the environment for the build (gather/update sources)
# Runs in /var/cache/deployd/<...>/upstream/sources
prepare() {
prevsrc # Get previous git repo if possible
if [ -d ari.lt/.git ]; then
cd ari.lt
git pull
cd ..
else
git clone https://git.ari.lt/ari.lt/ari.lt
fi
}
# Build the website
# Runs in /var/cache/deployd/<...>/upstream/build
build() {
py3_venv
py3_requirements ari.lt/requirements.txt
py3_install pymysql gunicorn
}
# We are still in `build`, but now we should run tests
test() {
py3_venv
py3_install tox
cd ari.lt
if py3_version 310; then
tox
fi
}
# Clean build directory
cleanup() {
py3_venv
cd ari.lt
rm -rf .git
}
teardown() {
daemon_trystop ari.lt
}
# Now we deploy as root, still in `build`
deploy() {
credentials_load
py3_venv
cd ari.lt/src
daemon_exec ari.lt /bin/sh -c "
export DB='mysql+pymysql://$CRED_DB_USER:$CRED_DB_PW@127.0.0.1/$CRED_DB_NAME?charset=utf8mb4'
export EMAIL_USER='$CRED_EMAIL'
export EMAIL_SERVER='$CRED_EMAIL_SERVER'
export EMAIL_PASSWORD='$CRED_EMAIL_PASSWORD'
export ADMIN_KEY='$CRED_EMAIL_KEY'
export MEMCACHED='127.0.0.1:11211'
exec $PY3_PYTHON -m gunicorn -b 127.0.0.1:17312 -w 1 main:app
"
}
sysadmin() {
id
}
# Then we symlink the latest build with the DEPLOY_TARGET