24 أسطر
688 B
Docker
24 أسطر
688 B
Docker
# Use an official Python runtime as a parent image
|
|
FROM python:3.9-slim
|
|
|
|
# Set the working directory in the container
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
# Prevents Python from writing .pyc files to disk
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
# Prevents Python from buffering stdout and stderr
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
# Install dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy the current directory contents into the container at /app
|
|
COPY main.py .
|
|
|
|
# Make port 8000 available to the world outside this container
|
|
EXPOSE 8000
|
|
|
|
# Define the command to run your app using uvicorn
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |