File size: 1,417 Bytes
b221b87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

# 建立開發環境映像檔 (如果還沒建立的話)
echo "Building dev environment image..."
sudo docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t fitai-dev -f Dockerfile.dev .

# 運行開發環境容器,並掛載相關設定
echo "Starting dev container..."
# 確保本地目錄存在,以免 docker 掛載成資料夾
mkdir -p ~/.claude ~/.codex
touch ~/.claude.json

# 執行容器並在背景完成 Claude 插件設定 (如果尚未設定)
sudo docker run -d \
    --name fitai-dev-env \
    -v "$(pwd)":/workspace \
    -v ~/.gitconfig:/home/developer/.gitconfig:ro \
    -v ~/.ssh:/home/developer/.ssh:ro \
    -v ~/.claude.json:/home/developer/.claude.json \
    -v ~/.claude:/home/developer/.claude \
    -v ~/.codex:/home/developer/.codex \
    --network="host" \
    fitai-dev /bin/bash -c "
        # 等待一下確保環境就緒
        sleep 2
        # 檢查並安裝 codex 插件
        if ! claude plugin list | grep -q 'codex'; then
            echo 'Configuring Claude plugins...'
            claude plugin marketplace add openai/codex-plugin-cc || true
            claude plugin install codex@openai-codex || true
        fi
        tail -f /dev/null
    "

echo "Container started. You can now attach to it using: sudo docker exec -it fitai-dev-env /bin/bash"
echo "Inside the container, run 'claude' and then '/codex:setup' to complete authentication."