Lesson 7 of 8 · 2 min
Deploy
cat > Dockerfile <<'DOCKER' FROM python:3.12-slim WORKDIR /srv COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY app app RUN useradd -m runner && chown -R runner /srv USER runner CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] DOCKER pip freeze > requirements.txt docker build -t myproject . && docker run -p 8000:8000 myproject
Push to GitHub, connect the repository to a container host such as Render, Railway or Fly, and set secrets in the host's settings, never in the repository. A free instance sleeps when idle; say so in your README.
