Skip to content
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
72 changes: 72 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Git
.git
.gitignore
.gitattributes

# Documentation
*.md
docs/
README*

# IDE
.vscode
.idea
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Logs
logs/
*.log

# Node modules (will be installed in container)
node_modules/
frontend/node_modules/

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
python/.venv/
*.egg-info/
dist/
build/

# Environment
.env
.env.local
.env.*.local

# Database
*.db
*.db-journal
valuecell.db

# LanceDB
lancedb/

# Build artifacts
frontend/build/
frontend/dist/
*.tsbuildinfo

# Tauri
frontend/src-tauri/target/

# Docker
docker-compose*.yml
Dockerfile*
.dockerignore

# Other
*.code-workspace
Makefile
start.sh
start.ps1

3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker/entrypoint.sh text eol=lf


47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
services:
backend:
build:
context: .
dockerfile: docker/Dockerfile.backend
container_name: valuecell-backend
ports:
- "8000:8000"
volumes:
- ./python:/app/python
- ./logs:/app/logs
- ./data:/app/data
- ./lancedb:/app/lancedb
environment:
- API_HOST=0.0.0.0
- API_PORT=8000
- CORS_ORIGINS=http://localhost:1420,http://localhost:3000
- VALUECELL_SQLITE_DB=sqlite:////app/data/valuecell.db
env_file:
- .env
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/healthz"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s

frontend:
build:
context: .
dockerfile: docker/Dockerfile.frontend
container_name: valuecell-frontend
ports:
- "1420:1420"
volumes:
- ./frontend:/app/frontend
- /app/frontend/node_modules
environment:
- NODE_ENV=development
- VITE_API_BASE_URL=http://localhost:8000/api/v1
- TAURI_DEV_HOST=0.0.0.0
depends_on:
- backend
restart: unless-stopped


68 changes: 68 additions & 0 deletions docker/Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM docker.1ms.run/astral/uv:python3.12-bookworm-slim

# Configure apt to use Aliyun mirror (for Debian)
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources || \
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list || true

# Install system dependencies including OpenSSL and CA certificates
RUN apt-get update && apt-get install -y \
curl \
openssl \
ca-certificates \
libssl3 \
sqlite3 \
&& rm -rf /var/lib/apt/lists/* \
&& update-ca-certificates


WORKDIR /app

# Copy Python project files
COPY python/pyproject.toml python/uv.lock ./python/
COPY python/README.md ./python/README.md
COPY python/scripts ./python/scripts
COPY python/valuecell ./python/valuecell
COPY python/configs ./python/configs

# Configure uv to use PyPI mirror (Tsinghua)
# Create pip config for uv to use mirror
RUN mkdir -p /root/.pip && \
echo "[global]" > /root/.pip/pip.conf && \
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf && \
echo "[install]" >> /root/.pip/pip.conf && \
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.pip/pip.conf

# Also set environment variable for uv
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple

# Pre-cache the application dependencies
# Try with --locked first, fallback to without if lockfile is outdated
RUN --mount=type=cache,target=/root/.cache/uv \
cd python && (uv sync --locked --no-install-project || uv sync --no-install-project)

# Install the application dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
cd python && (uv sync --locked || uv sync)

# Create logs directory
RUN mkdir -p /app/logs

# Copy entrypoint script
COPY docker/entrypoint.sh /app/entrypoint.sh
# Normalize line endings to LF (handle CRLF from Windows) and make executable
RUN sed -i 's/\r$//' /app/entrypoint.sh && chmod +x /app/entrypoint.sh

# Set entrypoint
ENTRYPOINT ["/app/entrypoint.sh"]

EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/api/v1/healthz || exit 1

# Run the backend server
WORKDIR /app/python
CMD ["uv", "run", "-m", "valuecell.server.main"]

40 changes: 40 additions & 0 deletions docker/Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Use bun image from domestic mirror (docker.1ms.run)
FROM docker.1ms.run/oven/bun:1.3.0-slim

# Configure apt to use Aliyun mirror (for Debian)
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources || \
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list || true

# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy frontend files
COPY frontend/package.json frontend/bun.lock ./frontend/

# Configure bun to use npm registry mirror (Taobao)
RUN echo "registry=https://registry.npmmirror.com" > /root/.npmrc && \
echo "_authToken=" >> /root/.npmrc

# Set environment variable for bun registry
ENV BUN_CONFIG_REGISTRY=https://registry.npmmirror.com

# Install dependencies
RUN cd frontend && bun install --frozen-lockfile

# Copy frontend source code
COPY frontend ./frontend

EXPOSE 1420

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD curl -f http://localhost:1420 || exit 1

# Run the frontend dev server
WORKDIR /app/frontend
CMD ["bun", "run", "dev"]

Loading