Last active
May 19, 2020 23:23
-
-
Save jalakoo/0492d85c0260e17e455a2caac6e3e1ca to your computer and use it in GitHub Desktop.
Convenience Bash script for deploying alwaysAI apps to Balena
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############ | |
# Simple script for preparing and deploying an alwaysAI app to Balena | |
# app_name arg should match the name of the application created in Balena | |
# To make this script runnable: run `chmod +x _name_of_this_script_.sh` in your command line | |
# NOTE: The entire app should exist in it's own repo. | |
############ | |
# Extract app name from arg if present | |
if [ $# -eq 1 ]; then | |
app_name="$1" | |
else | |
# If not - run interactive prompt to get it | |
echo 'Balena app name: ' | |
read app_name | |
fi | |
# If no app name available - halt script as push will eventually fail without it | |
if [ -z $app_name ]; then | |
echo 'No Balena app name argument provided' | |
exit 1 | |
fi | |
# Download models from alwaysAI | |
# NOTE for LINUX users: ALWAYSAI_HOME will need to be set prior to this | |
if ALWAYSAI_HOME=$(pwd) aai app install; then | |
# Create a docker template file that Balena will use | |
cp Dockerfile Dockerfile.template | |
echo 'WORKDIR /app' >> Dockerfile.template | |
echo 'COPY . ./' >> Dockerfile.template | |
echo 'CMD ["python3", "app.py"]' >> Dockerfile.template | |
# Push this repo up to Balena | |
if balena push $app_name; then | |
echo 'Deployment to Balena was successful' | |
else | |
echo 'Problem deploying to Balena.' | |
fi | |
else | |
echo "Error installing models. Check internet connection and login status." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment