Adds langfuse ec2 and api key to code
This commit is contained in:
66
infra/langfuse-terraform/user_data.sh.tftpl
Normal file
66
infra/langfuse-terraform/user_data.sh.tftpl
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Install Docker
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y ca-certificates curl gnupg git
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo groupadd docker || true
|
||||
sudo usermod -aG docker ubuntu
|
||||
sudo chmod 666 /var/run/docker.sock
|
||||
sudo systemctl enable docker
|
||||
sudo systemctl restart docker
|
||||
|
||||
# Clone and configure Langfuse
|
||||
cd /opt
|
||||
git clone ${langfuse_repo_url}
|
||||
cd langfuse
|
||||
|
||||
NEXTAUTH_SECRET=$(openssl rand -hex 32)
|
||||
PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
|
||||
SALT=$(openssl rand -hex 16)
|
||||
ENCRYPTION_KEY=$(openssl rand -hex 32)
|
||||
|
||||
cat > .env <<EOF
|
||||
NEXTAUTH_SECRET=$NEXTAUTH_SECRET
|
||||
NEXTAUTH_URL=http://$PUBLIC_IP:${langfuse_web_port}
|
||||
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres
|
||||
CLICKHOUSE_URL=http://clickhouse:8123
|
||||
CLICKHOUSE_USER=clickhouse
|
||||
CLICKHOUSE_PASSWORD=clickhouse
|
||||
TELEMETRY_ENABLED=false
|
||||
SALT=$SALT
|
||||
ENCRYPTION_KEY=$ENCRYPTION_KEY
|
||||
REDIS_AUTH=myredissecret
|
||||
LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID=minio
|
||||
LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY=miniosecret
|
||||
LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_ID=minio
|
||||
LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY=miniosecret
|
||||
LANGFUSE_S3_BATCH_EXPORT_ACCESS_KEY_ID=minio
|
||||
LANGFUSE_S3_BATCH_EXPORT_SECRET_ACCESS_KEY=miniosecret
|
||||
MINIO_ROOT_USER=minio
|
||||
MINIO_ROOT_PASSWORD=miniosecret
|
||||
EOF
|
||||
|
||||
sudo docker compose -f docker-compose.yml up -d
|
||||
|
||||
# Mount additional EBS volume
|
||||
DEVICE="${ebs_device_name}"
|
||||
MOUNT_DIR="/mnt/langfuse-data"
|
||||
|
||||
if [ -b "$DEVICE" ]; then
|
||||
sudo mkfs -t ext4 $DEVICE
|
||||
sudo mkdir -p $MOUNT_DIR
|
||||
sudo mount $DEVICE $MOUNT_DIR
|
||||
echo "$DEVICE $MOUNT_DIR ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
|
||||
else
|
||||
echo "Volume $DEVICE not found."
|
||||
fi
|
||||
Reference in New Issue
Block a user