Skip to content

Commit

Permalink
update staging for new tidploy
Browse files Browse the repository at this point in the history
  • Loading branch information
tiptenbrink committed Dec 14, 2023
1 parent e40caaa commit bf71111
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 20 deletions.
3 changes: 1 addition & 2 deletions deploy/build/deploy/staging/confspawn_tidploy.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"dployer": true,
"info": {
"latest": "{{ confspawn_env.git_ref }}"
},
"secrets": {
"dployer_env": "BWS_ACCESS_TOKEN",
"env_var": "BWS_ACCESS_TOKEN",
"ids": [
"fad6f227-e0fb-46f9-9380-b0ce0130e122",
"02134621-a2cc-4a96-a695-b0ce0131081f",
Expand Down
26 changes: 25 additions & 1 deletion deploy/build/deploy/staging/dployer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
#!/bin/bash

cleanup() {
echo
echo "Removing pipe..."
rm -f deploypipe
exit 1
}

# if you do Ctrl+C it will run cleanup
trap cleanup SIGINT

# remove the pipe if it somehow still exists
rm -f deploypipe
# create a named fifo pipe at ./deploypipe
mkfifo deploypipe
docker run -e BWS_ACCESS_TOKEN -v ./deploypipe:/dployer/ti_dploy_pipe -v ./tidploy.json:/dployer/tidploy.json ghcr.io/tiptenbrink/bws-dployer:latest & ./source.sh ./deploypipe
# run the deployer, providing it with the Secrets Manager access token and
# mounting the named pipe as well as the JSON containing the secrets to the
# container
# the process is started in the background (the '&') and then we run our
# previous script with the name of the pipe as the first argument
docker run \
-e BWS_ACCESS_TOKEN \
-v ./deploypipe:/dployer/ti_dploy_pipe \
-v "./tidploy.json:/dployer/tidploy.json" \
ghcr.io/tiptenbrink/bws-dployer:latest & \
./source.sh ./deploypipe
# finally we clean up the pipe by removing it
rm deploypipe
16 changes: 9 additions & 7 deletions deploy/build/deploy/staging/source.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash
# we want to auto-export all environment variables we set so docker compose can use them
set -a
echo "Waiting for secrets..."
while [ true ]
do
# if file exists and is named pipe
if [ -p "$1" ]; then
echo "Loaded secret."
. $1
if [ -n "$TIDPLOY_READY" ]; then
echo "Starting...."
./entrypoint.sh
break
else
echo "Secrets loaded."
fi
# if pipe doesn't exist we don't want to run too many loops
else
sleep 1
fi

if [ -n "$TIDPLOY_READY" ]; then
echo "Starting...."
./entrypoint.sh
break
fi
done
26 changes: 25 additions & 1 deletion deploy/use/staging/dployer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
#!/bin/bash

cleanup() {
echo
echo "Removing pipe..."
rm -f deploypipe
exit 1
}

# if you do Ctrl+C it will run cleanup
trap cleanup SIGINT

# remove the pipe if it somehow still exists
rm -f deploypipe
# create a named fifo pipe at ./deploypipe
mkfifo deploypipe
docker run -e BWS_ACCESS_TOKEN -v ./deploypipe:/dployer/ti_dploy_pipe -v ./tidploy.json:/dployer/tidploy.json ghcr.io/tiptenbrink/bws-dployer:latest & ./source.sh ./deploypipe
# run the deployer, providing it with the Secrets Manager access token and
# mounting the named pipe as well as the JSON containing the secrets to the
# container
# the process is started in the background (the '&') and then we run our
# previous script with the name of the pipe as the first argument
docker run \
-e BWS_ACCESS_TOKEN \
-v ./deploypipe:/dployer/ti_dploy_pipe \
-v "./tidploy.json:/dployer/tidploy.json" \
ghcr.io/tiptenbrink/bws-dployer:latest & \
./source.sh ./deploypipe
# finally we clean up the pipe by removing it
rm deploypipe
16 changes: 9 additions & 7 deletions deploy/use/staging/source.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash
# we want to auto-export all environment variables we set so docker compose can use them
set -a
echo "Waiting for secrets..."
while [ true ]
do
# if file exists and is named pipe
if [ -p "$1" ]; then
echo "Loaded secret."
. $1
if [ -n "$TIDPLOY_READY" ]; then
echo "Starting...."
./entrypoint.sh
break
else
echo "Secrets loaded."
fi
# if pipe doesn't exist we don't want to run too many loops
else
sleep 1
fi

if [ -n "$TIDPLOY_READY" ]; then
echo "Starting...."
./entrypoint.sh
break
fi
done
3 changes: 1 addition & 2 deletions deploy/use/staging/tidploy.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"dployer": true,
"info": {
"latest": "main"
},
"secrets": {
"dployer_env": "BWS_ACCESS_TOKEN",
"env_var": "BWS_ACCESS_TOKEN",
"ids": [
"fad6f227-e0fb-46f9-9380-b0ce0130e122",
"02134621-a2cc-4a96-a695-b0ce0131081f",
Expand Down

0 comments on commit bf71111

Please sign in to comment.