Dockerfile 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. # Use the official lightweight Python image.
  2. # https://hub.docker.com/_/python
  3. FROM python:3.9-slim
  4. # Ensure Python outputs everything immediately (useful for real-time logging in Docker).
  5. ENV PYTHONUNBUFFERED 1
  6. # Set the working directory in the container.
  7. WORKDIR /app
  8. # Update the system packages and install system-level dependencies required for compilation.
  9. # gcc: Compiler required for some Python packages.
  10. # build-essential: Contains necessary tools and libraries for building software.
  11. RUN apt-get update && apt-get install -y --no-install-recommends \
  12. gcc \
  13. build-essential \
  14. && rm -rf /var/lib/apt/lists/*
  15. # Copy the project's requirements file into the container.
  16. COPY requirements.txt /app/
  17. # Upgrade pip for the latest features and install the project's Python dependencies.
  18. RUN pip install --upgrade pip && pip install -r requirements.txt
  19. # Copy the entire project into the container.
  20. # This may include all code, assets, and configuration files required to run the application.
  21. COPY . /app/
  22. # Expose port 1337
  23. EXPOSE 1337
  24. # Define the default command to run the app using Python's module mode.
  25. CMD ["python", "-m", "g4f.api.run"]