From c769c971a7b61b1c771ad49d802e558c9d7dc228 Mon Sep 17 00:00:00 2001 From: MarkLo Date: Fri, 21 Nov 2025 09:22:14 +0800 Subject: [PATCH] --- backend/Dockerfile | 18 ++++++++---------- frontend/Dockerfile | 9 ++++++--- railway.toml | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 railway.toml diff --git a/backend/Dockerfile b/backend/Dockerfile index d25393be..83a0f0ca 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -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 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 76179a7e..34b53d18 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -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 diff --git a/railway.toml b/railway.toml new file mode 100644 index 00000000..8901b4aa --- /dev/null +++ b/railway.toml @@ -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"