Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add another ground service #13

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.npm
.node_repl_history
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# Build
dist/
build/
out/

# IDE
.idea/
.vscode/
*.swp
*.swo
.DS_Store
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM node:20-alpine as builder

WORKDIR /app

# 复制项目文件
COPY package*.json ./
COPY tsconfig.json ./
COPY vite.config.ts ./
COPY postcss.config.js ./
COPY tailwind.config.ts ./
COPY drizzle.config.ts ./
COPY theme.json ./
COPY client/ ./client/
COPY server/ ./server/
COPY db/ ./db/

# 安装依赖并构建
RUN npm ci
RUN npm run build

# 生产环境
FROM node:20-alpine

WORKDIR /app

# 复制构建产物和必要文件
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./

# 安装生产依赖,确保包含 vite
RUN npm ci --omit=dev && npm install vite@latest

# 设置环境变量
ENV NODE_ENV=production

# 检查必需的环境变量
ARG GOOGLE_API_KEY
ENV GOOGLE_API_KEY=$GOOGLE_API_KEY
RUN if [ -z "$GOOGLE_API_KEY" ] ; then echo "GOOGLE_API_KEY is required" && exit 1; fi

# 设置默认的 BASE_URL
ENV BASE_URL=https://generativelanguage.googleapis.com

# 暴露端口(使用 ARG 指令允许在构建时传入端口值)
ARG PORT=3000
ENV PORT=$PORT
EXPOSE $PORT

# 启动应用
CMD ["npm", "start"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Created by [@ammaar](https://x.com/ammaar)
- Node.js (v18 or higher recommended)
- npm or yarn
- A Google API key with access to Gemini API
- (Optional) A Search1API key for alternative search backend

### Installation

Expand Down Expand Up @@ -63,10 +64,36 @@ Created by [@ammaar](https://x.com/ammaar)
http://localhost:3000
```

### Docker Deployment

1. Build and run with docker-compose:
```bash
docker-compose up -d
```

2. Or run with custom port:
```bash
PORT=3125 docker-compose up -d
```

## Environment Variables

- `GOOGLE_API_KEY`: Your Google API key with access to Gemini API
- `NODE_ENV`: Set to "development" by default, use "production" for production builds
- `PORT`: (Optional) Custom port for the server, defaults to 3000
- `BASE_URL`: (Optional) Custom Gemini API endpoint
- `SEARCH1_API_KEY`: (Optional) Required if using search1api tool instead of Google Search

## Search Tools

The project supports two search backends:
1. **Google Search** (default): Uses Google's built-in search capability
2. **Search1API**: An alternative search backend ([search1api.com](https://search1api.com)) that:
- Costs 5x less than Google Search
- Response time is 2x slower than Google Search
- Requires:
- Set `BASE_URL=https://ground.search1api.com`
- Set `SEARCH1_API_KEY=your_search1api_key`

## Development

Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
args:
- GOOGLE_API_KEY=${GOOGLE_API_KEY:?GOOGLE_API_KEY is required}
- PORT=${PORT:-3000}
ports:
- "${PORT:-3000}:${PORT:-3000}"
environment:
- NODE_ENV=production
- GOOGLE_API_KEY=${GOOGLE_API_KEY:?GOOGLE_API_KEY is required}
- BASE_URL=${BASE_URL:-https://generativelanguage.googleapis.com}
- SEARCH1_API_KEY=${SEARCH1_API_KEY:-}
- PORT=${PORT:-3000}
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:${PORT:-3000}/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s

networks:
default:
driver: bridge
4 changes: 2 additions & 2 deletions node_modules/.vite/deps/@radix-ui_react-scroll-area.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions node_modules/.vite/deps/@radix-ui_react-toast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 23 additions & 23 deletions node_modules/.vite/deps/_metadata.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading