31 lines
913 B
Docker
31 lines
913 B
Docker
#Create react build
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
COPY react-app/package*.json ./
|
|
RUN npm install --force
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Use an official lightweight Python image
|
|
FROM python:3.12-slim
|
|
|
|
# Prevent Python from writing .pyc files and enable real-time logging
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /code
|
|
|
|
# Copy only the dependency definitions to maximize Docker cache utilization
|
|
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
# Install the application dependencies
|
|
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
|
|
# Copy the rest of the application code
|
|
COPY ./app /code/app
|
|
COPY --from=builder /react-app/dist /code/app/static
|
|
COPY --from=builder /react-app/src/public /code/app/static
|
|
|
|
# Run the FastAPI application using the official CLI
|
|
CMD ["fastapi", "run", "app/main.py", "--port", "80"] |