Files
KisStock/Dockerfile

40 lines
951 B
Docker

# 1. Frontend Build Stage
FROM node:20-alpine AS frontend-build
WORKDIR /app/frontend
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# 2. Backend & Serving Stage
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy backend requirements
COPY ./backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend code (contents of backend folder to /app)
COPY ./backend/ .
# Copy frontend build artifacts to /app/static
COPY --from=frontend-build /app/frontend/dist ./static
# Ensure data directory exists
RUN mkdir -p /app/data
# Environment variables
ENV PORT=80
EXPOSE 80
# Run FastAPI server
# Since app/ is now directly in /app, uvicorn app.main:app works
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]