Update README and deploy script for stacks

This commit is contained in:
Joey Hafner 2024-09-04 13:11:41 -07:00
parent 2d74957257
commit 062391ff28
No known key found for this signature in database
2 changed files with 30 additions and 9 deletions

View File

@ -1,16 +1,15 @@
# Stacks: Atomic Services using Docker Compose
### Get a Stack (from source with Git)
### Build a Stack (from source with Git)
```sh
STACK=ai
STACK=gitea-runner
mkdir -p $HOME/stacks/$STACK
git clone -n --depth=1 --filter=tree:0 https://gitea.jafner.tools/Jafner/Jafner.net.git /tmp/repo
cd /tmp/repo
git sparse-checkout set --no-cone homelab/stacks/$STACK
git checkout
mv homelab/stacks/$STACK $HOME/stacks/
cd $HOME/stacks/$STACK
zip -r $STACK.zip homelab/stacks/$STACK
rm -rf /tmp/repo
```
@ -20,3 +19,19 @@ This will clone the stack from the repo into a tmp directory, extract the stack
- This *does not* bring up the stack.
- This *does* require Git.
### Pull a Stack (from source with Git)
```sh
STACK=books
mkdir -p /tmp/stack/$STACK
git clone -n --depth=1 --filter=tree:0 https://gitea.jafner.tools/Jafner/Jafner.net.git /tmp/stack/$STACK && cd /tmp/stack/$STACK
git sparse-checkout set --no-cone homelab/stacks/$STACK && git checkout
mv homelab/stacks/$STACK $HOME/stacks/
cd $HOME/stacks/$STACK && rm -rf /tmp/stack/$STACK
echo -e "$(cat $HOME/.age/$HOSTNAME.host.key)\n$AGE_DEPLOY_KEY" > $HOME/.age/combined.key
export SOPS_AGE_KEY_FILE="$HOME/.age/combined.key"
for file in $(find . -type f); do
sops decrypt -i --input-type json "$file" 2>/dev/null && echo "Decrypted $file"
done
```

View File

@ -10,8 +10,14 @@ mv -f homelab/stacks/$STACK/* $HOME/stacks/$STACK/
mv -f homelab/stacks/$STACK/.* $HOME/stacks/$STACK/
cd $HOME/stacks/$STACK && rm -rf /tmp/stack/$STACK
echo -e "$(cat $HOME/.age/$HOSTNAME.host.key)\n$AGE_DEPLOY_KEY" > $HOME/.age/combined.key
export SOPS_AGE_KEY_FILE="$HOME/.age/combined.key"
for file in $(find . -type f); do
sops decrypt -i --input-type json "$file" 2>/dev/null && echo "Decrypted $file"
done
if [[ -z $AGE_DEPLOY_KEY ]]; then
echo "Error: AGE_DEPLOY_KEY not set. Cannot decrypt secrets."
else
echo -e "$(cat $HOME/.age/$HOSTNAME.host.key)\n$AGE_DEPLOY_KEY" > $HOME/.age/combined.key
export SOPS_AGE_KEY_FILE="$HOME/.age/combined.key"
for file in $(find . -type f); do
sops decrypt -i --input-type json "$file" 2>/dev/null && echo "Decrypted $file"
done
fi
docker compose -f $HOME/stacks/$STACK/docker-compose.yml pull