dynamic teleport injection for react dev container
Build and Push Docker Images / build-and-push (push) Successful in 29s

This commit is contained in:
Bram Kelchtermans
2024-08-19 16:22:50 +02:00
parent 90075f2a1a
commit 7fa33aced7
2 changed files with 30 additions and 22 deletions
+30 -12
View File
@@ -7,22 +7,22 @@ if [ -z "$REPO_URL" ]; then
exit 1
fi
# Check if the SSH key exists
if [ ! -f /root/.ssh/id_rsa ]; then
echo "Error: SSH private key not found at /root/.ssh/id_rsa"
exit 1
fi
if [ -z $GIT_USER ]; then
if [ -z "$GIT_USER" ]; then
echo "Error: GIT_USER environment variable must be set."
exit 1
fi
if [ -z $GIT_EMAIL ]; then
if [ -z "$GIT_EMAIL" ]; then
echo "Error: GIT_EMAIL environment variable must be set."
exit 1
fi
# Check if the SSH key exists
if [ ! -f /root/.ssh/id_rsa ]; then
echo "Error: SSH private key not found at /root/.ssh/id_rsa"
exit 1
fi
# Ensure the SSH key has the correct permissions
chmod 600 /root/.ssh/id_rsa
@@ -46,6 +46,19 @@ if [ -f /root/.ssh/hostkey.pub ]; then
cat /root/.ssh/hostkey.pub >>/root/.ssh/authorized_keys
fi
# If no teleport edition is given, fallback to oss
if [ -z "$TELEPORT_EDITION" ]; then
TELEPORT_EDITION="oss"
fi
# Install Teleport if the environment variables are set
if [ -n "$TELEPORT_VERSION" ] && [ -n "$TELEPORT_URL" ]; then
echo "Installing Teleport version $TELEPORT_VERSION, edition $TELEPORT_EDITION..."
curl https://${TELEPORT_URL}/install-v${TELEPORT_VERSION}.sh | bash -s ${TELEPORT_VERSION} ${TELEPORT_EDITION}
else
echo "Error: TELEPORT_VERSION and TELEPORT_EDITION environment variables must be set."
fi
# Change to the repository directory
cd /workspace
@@ -66,11 +79,16 @@ git config --global user.email $GIT_EMAIL
# Get the hostname of the machine
HOSTNAME=$(hostname)
# File path
CONFIG_FILE="/etc/teleport.yaml"
# # File path
# CONFIG_FILE="/etc/teleport.yaml"
# Edit the teleport.yaml file to update the nodename
sed -i "s/^ nodename:.*/ nodename: $HOSTNAME/" "$CONFIG_FILE"
# # Edit the teleport.yaml file to update the nodename
# sed -i "s/^ nodename:.*/ nodename: $HOSTNAME/" "$CONFIG_FILE"
## If teleport token is set, join the server
if [ -n "$TELEPORT_TOKEN" ]; then
teleport configure --roles=node --token=$TELEPORT_TOKEN --proxy=$TELEPORT_URL -o file
fi
nohup teleport start &
# Start the application with pm2