teleport optional
Build and Push Docker Images / build-and-push (push) Successful in 3m17s

This commit is contained in:
Bram Kelchtermans
2024-12-11 11:32:24 +01:00
parent e9fb3558db
commit 9881e7eb7d
3 changed files with 34 additions and 29 deletions
+9 -1
View File
@@ -8,7 +8,15 @@ WORKDIR /workspace
RUN npm install -g pm2 RUN npm install -g pm2
# Install git, openssh-client, openssh-server, and other necessary packages # Install git, openssh-client, openssh-server, and other necessary packages
RUN apt-get update && apt-get install -y git openssh-client openssh-server software-properties-common sudo RUN apt-get update && apt-get install -y \
git \
openssh-client \
openssh-server \
software-properties-common \
sudo \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install additional package managers # Install additional package managers
RUN npm install -g pnpm RUN npm install -g pnpm
+21 -24
View File
@@ -39,21 +39,34 @@ fi
# Set default package manager if not provided # Set default package manager if not provided
PACKAGE_MANAGER=${PACKAGE_MANAGER:-npm} PACKAGE_MANAGER=${PACKAGE_MANAGER:-npm}
# If no teleport edition is given, fallback to oss # Optional Teleport setup
TELEPORT_EDITION=${TELEPORT_EDITION:-oss} if [ -n "$TELEPORT_VERSION" ] && [ -n "$TELEPORT_URL" ] && [ -n "$TELEPORT_TOKEN" ]; then
echo "Teleport configuration detected. Setting up Teleport..."
# Install Teleport if the environment variables are set # Set default edition if not provided
if [ -n "$TELEPORT_VERSION" ] && [ -n "$TELEPORT_URL" ]; then TELEPORT_EDITION=${TELEPORT_EDITION:-oss}
# Only install Teleport if it's not already installed
if ! command -v teleport &> /dev/null; then
echo "Installing Teleport version $TELEPORT_VERSION, edition $TELEPORT_EDITION..." echo "Installing Teleport version $TELEPORT_VERSION, edition $TELEPORT_EDITION..."
curl https://goteleport.com/static/install.sh | bash -s "${TELEPORT_VERSION}" "${TELEPORT_EDITION}" curl https://goteleport.com/static/install.sh | bash -s "${TELEPORT_VERSION}" "${TELEPORT_EDITION}"
fi
# If teleport token is set and there is no teleport.yaml file, create one # Create teleport configuration
if [ -n "$TELEPORT_TOKEN" ] && [ ! -f /etc/teleport.yaml ]; then
teleport configure --roles=node --token="$TELEPORT_TOKEN" --proxy="$TELEPORT_URL" --no-acme -o file teleport configure --roles=node --token="$TELEPORT_TOKEN" --proxy="$TELEPORT_URL" --no-acme -o file
echo "Created teleport configuration file" echo "Created teleport configuration file"
fi
# Get the hostname of the machine
HOSTNAME=$(hostname)
# Update nodename in teleport config
sed -i "s/^ nodename:.*/ nodename: $HOSTNAME/" /etc/teleport.yaml
# Start Teleport in the background
echo "Starting Teleport service..."
nohup teleport start &
else else
echo "Warning: TELEPORT_VERSION and TELEPORT_URL environment variables are not set. Skipping Teleport installation." echo "Skipping Teleport setup - credentials not provided"
fi fi
# Ensure the SSH key has the correct permissions # Ensure the SSH key has the correct permissions
@@ -114,22 +127,6 @@ fi
git config --global user.name "$GIT_USER" git config --global user.name "$GIT_USER"
git config --global user.email "$GIT_EMAIL" git config --global user.email "$GIT_EMAIL"
# Get the hostname of the machine
HOSTNAME=$(hostname)
# File path
CONFIG_FILE="/etc/teleport.yaml"
# Edit the teleport.yaml file to update the nodename if the file exists
if [ -f "$CONFIG_FILE" ]; then
sed -i "s/^ nodename:.*/ nodename: $HOSTNAME/" "$CONFIG_FILE"
# Start Teleport in the background
nohup teleport start &
else
echo "Warning: Teleport configuration file not found. Skipping Teleport start."
fi
# Start SSH server # Start SSH server
service ssh start service ssh start
+1 -1
View File
@@ -1 +1 @@
3.0 3.1