克隆代码
git clone https://github.com/abi/screenshot-to-code.git
构建 frontend
cd frontend/
docker build -t screenshot-to-code-frontend:latest -f ./Dockerfile .
docker images | grep screenshot-to-code-frontend
构建 backend
cd backend/
docker build -t screenshot-to-code-backend:latest -f ./Dockerfile .
docker images | grep screenshot-to-code-backend
运行 frontend
docker rm -f screenshot-to-code-frontend
docker run –name screenshot-to-code-frontend -d \
–network host \
-e VITE_WS_BACKEND_URL=”ws://{your machine ip}:7001″ \
screenshot-to-code-frontend:latest
docker ps | grep screenshot-to-code-frontend
运行 backend
docker rm -f screenshot-to-code-backend
docker run –name screenshot-to-code-backend -d \
–network host \
-e OPENAI_API_KEY=”{your_openai_api_key}” \
screenshot-to-code-backend:latest \
poetry run uvicorn main:app –host 0.0.0.0 –port 7001
docker ps | grep screenshot-to-code-backend
经过上述步骤后,screenshot-to-code 已成功运行,此时可通过服务器 IP + 5173 端口访问(需要设置相关安全组或防火墙规则,这里需要设置 5173 和 7001 两个端口)。
With the help of @abi this problem was solved. VITE_WS_BACKEND_URL=ws://IP_address:7001 needs to be configured in the ./frontend file. The IP_address here should be configured with the external IP.
After updating the code, you need to run docker-compose up -d –build