Skip to content

Commit

Permalink
Update kamal deployment config files
Browse files Browse the repository at this point in the history
  • Loading branch information
benbusby committed Dec 18, 2024
1 parent dc43f07 commit c1bc9fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ products.json

# Kamal
.kamal/secrets*
config/deploy.*.yml
config/*
!config/deploy.yml
!config/deploy.template.yml
7 changes: 7 additions & 0 deletions config/deploy.template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
servers:
SERVER_IP_ADDRESSES

# Inject ENV variables into containers (secrets come from .kamal/secrets.[mode]).
env:
secret:
ENV_LIST_SECRETS
7 changes: 6 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ENV_FILE="$MODE.env"
SECRETS_FILE=".kamal/secrets.$MODE"
DEPLOY_FILE="config/deploy.$MODE.yml"
DEPLOY_FILE_TEMPLATE="config/deploy.template.yml"
SSH_FILE="config/ssh.$MODE.yml"
ENV_SECRETS_TMP_FILE="$(mktemp)"
SERVER_IPS_TMP_FILE="$(mktemp)"

Expand Down Expand Up @@ -68,7 +69,7 @@ while IFS='=' read -r var_name var_value; do
elif [[ "$var_name" == *"KAMAL"* ]] || [[ "$var_name" == *"YEETFILE"* ]]; then
# Add to env secrets list
echo "$var_name=\$$var_name" >> "$SECRETS_FILE"
if [[ $var_name == "YEETFILE"* ]]; then
if [[ ! $var_name == *"KAMAL"* ]]; then
echo " - $var_name" >> "$ENV_SECRETS_TMP_FILE"
fi
fi
Expand All @@ -92,6 +93,10 @@ replace_in_file "$SERVER_IPS_STR_REPL" "$SERVER_IPS" "$DEPLOY_FILE"
rm -f "$ENV_SECRETS_TMP_FILE"
rm -f "$SERVER_IPS_TMP_FILE"

if [[ -f $SSH_FILE ]]; then
cat $SSH_FILE >> $DEPLOY_FILE
fi

read -r -p "Show secrets? (y/N): " input && [[ "$input" == "y" ]] && \
kamal secrets print -d "$MODE"
read -r -p "Ready to deploy? (y/N): " input && [[ "$input" == "y" ]] && \
Expand Down

0 comments on commit c1bc9fb

Please sign in to comment.