finance-advisor-agent / Dockerfile
Trae Agent
优化
3500a4b
# Stage 1: Build Frontend
FROM node:18-alpine as frontend-build
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install
COPY . .
RUN pnpm run build
# Stage 2: Serve with Flask
FROM python:3.10-slim
WORKDIR /app
# Install system dependencies if needed
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Backend Code
COPY . .
# Copy Frontend Build from Stage 1
COPY --from=frontend-build /app/dist /app/dist
# Create a non-root user for security (good practice for HF Spaces)
RUN useradd -m -u 1000 user
# Set ownership of the application directory to the non-root user
# This is crucial for SQLite database creation in the instance folder
RUN chown -R user:user /app
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose port 7860
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]