8
submitted 4 months ago* (last edited 4 months ago) by mapto@lemmy.world to c/python@programming.dev

I deploy a FastAPI service with docker (see my docker-compose.yml and app).

My service directory gets filled with files index.html, index.html.1, index.html.2,... that all contain

They seem to be generated any time the docker healthcheck pings the service.

How can I get rid of these?

PS: I had to put a screenshot, because Lemmy stripped my HTML in the code quote.

top 8 comments
sorted by: hot top controversial new old
[-] joyjoy@lemm.ee 5 points 4 months ago

In your docker-compose.yml file, your healthcheck for fastapi uses wget, which saves the file to disk by default. Add --spider to make it behave correctly. Your nginx service has the correct command.

[-] ishanpage@programming.dev 4 points 4 months ago

This is a FastAPI feature - Autogenerated documentation using Swagger.

You can turn it off by setting docs_url=None

In your linked main.py:

app = FastAPI(
    title="IslabTweet",
    description=__doc__,
    docs_url="/", # change this to None to disable the docs
    version=VERSION,
)

Hope this helps!

[-] taaz@biglemmowski.win 5 points 4 months ago* (last edited 4 months ago)

That's weird, I have never noticed any kind of .html files generation when accessing the docs and I have worked with F.Api for some time now, also can't seem to find ang mention of this generation in the docs (that it actually writes files).

Also isn't the default doc path /docs (/redoc)

[-] mapto@lemmy.world 2 points 4 months ago* (last edited 4 months ago)

Ok, that was stupid. Doing healthcheck with wget, does what wget does: it downloads the result. I had to add --spider to stop doing that

  wget -nv --spider http://localhost:8000 || exit 1
[-] taaz@biglemmowski.win 1 points 4 months ago* (last edited 4 months ago)

usually I would use just curl for hc

[-] mapto@lemmy.world 1 points 4 months ago

To me it depends on the base image. Some don't have curl, but have wget. I would go with the flow instead of installing it myself. Especially if I can get away with not having to add more layers for an image of my own and/or using the same command for all containers

[-] joyjoy@lemm.ee 3 points 4 months ago

The default is /docs

[-] mapto@lemmy.world 1 points 4 months ago

Well, I do need OpenAPI (Swagger). What I don't need is the generation of thousands of equal static files. Out of all these generated files, index.html would've been enough and I don't need index.html.1, etc.

this post was submitted on 07 Feb 2024
8 points (100.0% liked)

Python

5891 readers
39 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS