Commit ccdaa62a by Ivan

feat: update deploy

parent e1b89d94
...@@ -34,6 +34,52 @@ echo "after Setting up directories..." ...@@ -34,6 +34,52 @@ echo "after Setting up directories..."
# Wait for external volumes to be properly mounted # Wait for external volumes to be properly mounted
sleep 5 sleep 5
# 设置SSH配置以解决Host key verification failed问题
echo "Setting up SSH configuration..."
# 确保.ssh目录存在并具有正确的权限
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# 如果存在挂载的SSH目录,确保我们可以使用其中的密钥
if [ -d "/root/.ssh" ]; then
echo "Found mounted SSH directory, configuring access..."
# 复制SSH密钥到当前用户的.ssh目录
cp -f /root/.ssh/id_* ~/.ssh/ 2>/dev/null || echo "No SSH keys found in mounted directory"
cp -f /root/.ssh/config ~/.ssh/ 2>/dev/null || echo "No SSH config found in mounted directory"
# 确保密钥文件有正确的权限
chmod 600 ~/.ssh/id_* 2>/dev/null || echo "No SSH keys to chmod"
# 如果存在known_hosts文件,也复制它
if [ -f "/root/.ssh/known_hosts" ]; then
cp -f /root/.ssh/known_hosts ~/.ssh/
else
# 如果没有known_hosts文件,创建一个空文件
touch ~/.ssh/known_hosts
fi
# 禁用StrictHostKeyChecking以自动接受新的host keys
if [ ! -f "~/.ssh/config" ]; then
echo "Creating SSH config to disable strict host key checking..."
cat > ~/.ssh/config << 'EOL'
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOL
chmod 600 ~/.ssh/config
fi
fi
# 测试SSH连接
echo "Testing SSH connection to Git repository host..."
GIT_HOST=$(echo "${GIT_REPOSITORY}" | sed -E 's/.*@([^:]+):.*/\1/')
if [ "${GIT_HOST}" != "${GIT_REPOSITORY}" ]; then
echo "Detected Git host: ${GIT_HOST}"
ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${GIT_HOST} 2>&1 || echo "SSH connection test completed with non-zero exit code, but we'll continue anyway"
fi
# Check if code directory is empty or if we need to clone/pull the repository # Check if code directory is empty or if we need to clone/pull the repository
if [ -z "${GIT_REPOSITORY}" ]; then if [ -z "${GIT_REPOSITORY}" ]; then
echo "⚠️ GIT_REPOSITORY environment variable not set. Using mounted code directory." echo "⚠️ GIT_REPOSITORY environment variable not set. Using mounted code directory."
......
...@@ -101,7 +101,7 @@ volumes: ...@@ -101,7 +101,7 @@ volumes:
- "/root/img_manager/logs:/rails/log" - "/root/img_manager/logs:/rails/log"
# Tmp directory for pids and other temporary files # Tmp directory for pids and other temporary files
- "/root/img_manager/tmp:/rails/tmp" - "/root/img_manager/tmp:/rails/tmp"
- "/root/.ssh:/root/.ssh" - "/root/.ssh:/home/rails/.ssh"
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid # Bridge fingerprinted assets, like JS and CSS, between versions to avoid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment