diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4b27586 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +__pycache__/ +*.pyc +*.pyo +*.pyd +.git +.gitignore +.env +venv/ +.venv/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5a3e38 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# 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 + +# Run the FastAPI application using the official CLI +CMD ["fastapi", "run", "app/main.py", "--port", "80"] \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..d5f940f --- /dev/null +++ b/app/main.py @@ -0,0 +1,9 @@ +from fastapi import FastAPI + +# Создаем само приложение +app = FastAPI() + +# Вешаем обработчик на главную страницу +@app.get("/") +def read_root(): + return {"message": "Hello, world!"} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29