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
FROM python:3.13-slim as builder
FROM python:3.11-slim as builder
# Set working directory
WORKDIR /app
@ -10,15 +9,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
# Copy requirements from backend directory
COPY backend/requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Production stage
FROM python:3.13-slim
FROM python:3.11-slim
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/bin /usr/local/bin
# Copy application code
COPY ./app ./app
# Copy application code from backend directory
COPY backend/app ./app
# Copy tradingagents package from parent directory
# Note: This assumes docker-compose builds from project root with context
COPY ./tradingagents ./tradingagents
# Copy tradingagents package from project root
COPY tradingagents ./tradingagents
# Create results directory
RUN mkdir -p /app/results

View File

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