Files
ai-mail-server/Dockerfile

30 lines
869 B
Docker

# 1. Base Image
# Use a lightweight Python base image
FROM python:3.11-slim
# 2. Set Working Directory
# Set the working directory inside the container
WORKDIR /app
# 3. Install Dependencies
# Copy the requirements file first to leverage Docker's layer caching.
# This way, dependencies are only re-installed if requirements.txt changes.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 4. Copy Application Files
# Copy the rest of the application source code, including the 'web' directory
COPY . .
# 5. Expose Port
# Expose the port the app runs on
EXPOSE 8000
# 6. Add a healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/ || exit 1
# 7. Set Command
# Define the command to run the application.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]