I want to use a static HTML page in my docker to show logfiles via websockets and FastAPI inside a docker container. As FastAPI has already a webserver, I mount my static page with:
root_path = "/qgis"
app = FastAPI(
title="API",
description="API",
version=VERSION,
root_path=root_path
)
app.mount("/static", StaticFiles(directory="static"), name="static")
My folder structure is:
/api
|- main.py
|- Dockerfile
|- docker-compose.yml
|-static
|- index.html
|- style.css
|- Bilder
|-....
My docker-compose.yml contains:
services:
api:
image: api:entw
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
volumes:
- ./static:/app/static:rw
networks:
geonet_entw:
ports:
- "8000:8000"
networks:
entw:
external: true
However, when I start with https://my.url.de/qgis/docs I see all data provided by Swagger and can use them. If I use https://my.url.de/qgis/static/index.html I get an Error 404.
If I use putty to go inside the docker folder with docker exec -it docker_api sh and use lsI see the folder static with all data included.
Edit
When I use:
python3 -c "import urllib.request as r; print(r.urlopen('http://localhost:8000/qgis/static/index.html').read().decode())"
Inside the container (accessed via docker exec -it docker_api sh) I get the error:
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
From outside the container, I used curl -l https://my.url.de/qgis/static/index.html I get the message:
HTTP/1.1 404 Not Found
Server: nginx
...
html=True