This commit is contained in:
MarkLo 2025-11-21 09:22:14 +08:00
parent 2518eb3d49
commit c769c971a7
3 changed files with 30 additions and 13 deletions

View File

@ -1,6 +1,5 @@
# Multi-stage build for FastAPI backend # Multi-stage build for FastAPI backend
# Multi-stage build for FastAPI backend FROM python:3.11-slim as builder
FROM python:3.13-slim as builder
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
@ -10,15 +9,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \ build-essential \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copy requirements # Copy requirements from backend directory
COPY requirements.txt . COPY backend/requirements.txt .
# Install Python dependencies # Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \ RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt pip install --no-cache-dir -r requirements.txt
# Production stage # Production stage
FROM python:3.13-slim FROM python:3.11-slim
WORKDIR /app WORKDIR /app
@ -26,12 +25,11 @@ WORKDIR /app
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code # Copy application code from backend directory
COPY ./app ./app COPY backend/app ./app
# Copy tradingagents package from parent directory # Copy tradingagents package from project root
# Note: This assumes docker-compose builds from project root with context COPY tradingagents ./tradingagents
COPY ./tradingagents ./tradingagents
# Create results directory # Create results directory
RUN mkdir -p /app/results RUN mkdir -p /app/results

View File

@ -6,9 +6,12 @@ FROM base AS deps
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install dependencies # Install dependencies
COPY package.json package-lock.json* ./ COPY package.json pnpm-lock.yaml* ./
RUN npm ci RUN pnpm install --frozen-lockfile
# Rebuild the source code only when needed # Rebuild the source code only when needed
FROM base AS builder FROM base AS builder
@ -20,7 +23,7 @@ COPY . .
ENV NEXT_PUBLIC_API_URL=http://backend:8000 ENV NEXT_PUBLIC_API_URL=http://backend:8000
# Build Next.js app # Build Next.js app
RUN npm run build RUN pnpm run build
# Production image, copy all the files and run next # Production image, copy all the files and run next
FROM base AS runner FROM base AS runner

16
railway.toml Normal file
View File

@ -0,0 +1,16 @@
[build]
builder = "dockerfile"
[deploy]
startCommand = ""
restartPolicyType = "on_failure"
[[services]]
name = "backend"
dockerfilePath = "backend/Dockerfile"
sourcePath = "."
[[services]]
name = "frontend"
dockerfilePath = "frontend/Dockerfile"
sourcePath = "frontend"