https://github.com/fastapi/fastapi
Create and activate a virtual environment and then install FastAPI:
$ pip install "fastapi[standard]"
---> 100%
Note: Make sure you put "fastapi[standard]"
in quotes to ensure it works in all terminals.
Run the server with:
$ fastapi dev main.py
╭────────── FastAPI CLI - Development mode ───────────╮
│ │
│ Serving at: http://127.0.0.1:8000 │
│ │
│ API docs: http://127.0.0.1:8000/docs │
│ │
│ Running in development mode, for production use: │
│ │
│ fastapi run │
│ │
╰─────────────────────────────────────────────────────╯
INFO: Will watch for changes in these directories: ['/home/user/code/awesomeapp']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [2248755] using WatchFiles
INFO: Started server process [2248757]
INFO: Waiting for application startup.
INFO: Application startup complete.
When you're ready, start your application by running:
docker compose up --build
.
Your application will be available at http://localhost:8000.
First, build your image, e.g.:
docker build -t myapp .
If your cloud uses a different CPU architecture than your development machine (e.g., you are on a Mac M1 and your cloud provider is amd64), you'll want to build the image for that platform, e.g.:
docker build --platform=linux/amd64 -t myapp .
.
Then, push it to your registry, e.g.
docker push myregistry.com/myapp
.
Consult Docker's getting started docs for more detail on building and pushing.