This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
if [ -n "$TELEPORT_VERSION" ] && [ -n "$TELEPORT_URL" ] && [ -n "$TELEPORT_TOKEN" ]; then
|
||||||
|
echo "Teleport configuration detected. Setting up Teleport..."
|
||||||
|
|
||||||
|
# Set default edition if not provided
|
||||||
TELEPORT_EDITION=${TELEPORT_EDITION:-oss}
|
TELEPORT_EDITION=${TELEPORT_EDITION:-oss}
|
||||||
|
|
||||||
# Install Teleport if the environment variables are set
|
# Only install Teleport if it's not already installed
|
||||||
if [ -n "$TELEPORT_VERSION" ] && [ -n "$TELEPORT_URL" ]; then
|
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 @@
|
|||||||
3.0
|
3.1
|
||||||
Reference in New Issue
Block a user