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
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ RUN npm ci \
&& npm ci --prefix frontend \
&& cd backend && uv sync

# Pre-seed the tiktoken BPE encodings at build time. CAMEL/OASIS token counting
# imports tiktoken, which otherwise downloads o200k_base/cl100k_base from
# openaipublic.blob.core.windows.net on first use — a runtime cloud dependency
# that crashes the simulation subprocess in offline or DNS-restricted
# environments. Baking them in keeps simulation runtime fully offline.
ENV TIKTOKEN_CACHE_DIR=/app/tiktoken_cache
RUN cd backend && uv run python -c "import tiktoken; tiktoken.get_encoding('o200k_base'); tiktoken.get_encoding('cl100k_base')"

# 复制项目源码
COPY . .

Expand Down
13 changes: 11 additions & 2 deletions backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@

# Load .env file from project root
# Path: MiroFish/.env (relative to backend/app/config.py)
#
# override=False is deliberate: real OS environment variables must win over the
# .env file. The Docker deployment feeds configuration into the container through
# the environment — docker-compose injects the vars from `.env` via `env_file:`
# (and NEO4J_URI must point at the compose service, e.g. bolt://neo4j:7687, not
# the localhost value that is only correct for native dev). With override=True a
# stray/baked .env would silently clobber that injection, so the backend would
# dial localhost inside the container and never reach the neo4j service. For
# native dev nothing changes: those vars aren't in the OS env, so .env still loads.
project_root_env = os.path.join(os.path.dirname(__file__), '../../.env')

if os.path.exists(project_root_env):
load_dotenv(project_root_env, override=True)
load_dotenv(project_root_env, override=False)
else:
# If no .env in root, try to load environment variables (for production)
load_dotenv(override=True)
load_dotenv(override=False)


class Config:
Expand Down