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
-10
View File
@@ -16,19 +16,9 @@ RUN rm -rf linux-presets
RUN usermod -aG sudo root
# SHELL [ "fish", "--command" ]
# RUN chsh -s /usr/bin/fish
# ENV SHELL /usr/bin/fish
# ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
# Create a directory for the SSH keys
RUN mkdir -p /root/.ssh
COPY install-node.sh /workspace/install-node.sh
RUN chmod +x /workspace/install-node.sh
RUN /workspace/install-node.sh
RUN rm /workspace/install-node.sh
# Copy the entrypoint script into the container
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
+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