Fixed packaging of static files

This commit is contained in:
Tris Forster 2025-09-29 23:02:39 +10:00
parent 4291c845d8
commit 9266a1f131
10 changed files with 11 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
__pycache__
dist
*.pyc

View File

@ -1,12 +1,12 @@
FROM recoll
RUN apt-get install breeze-icon-theme
RUN apt-get -y install breeze-icon-theme python3-venv
COPY . /opt/squirrel
WORKDIR /opt/squirrel
COPY dist/squirrel-0.3.0-py3-none-any.whl squirrel-0.3.0-py3-none-any.whl
RUN pip install --break-system-packages -e .
RUN python3 -m venv --system-site-packages /opt/squirrel
RUN /opt/squirrel/bin/pip install squirrel-0.3.0-py3-none-any.whl
EXPOSE 8000
ENTRYPOINT ["/bin/bash"]
ENTRYPOINT ["/opt/squirrel/bin/squirrel"]

View File

@ -5,6 +5,7 @@ from fastapi.templating import Jinja2Templates
from typing import Any
import logging
import subprocess
import os.path
from recoll import recoll
@ -15,6 +16,8 @@ from fastapi import BackgroundTasks
logger = logging.getLogger()
logging.basicConfig(level=logging.DEBUG)
SQUIRREL_FOLDER = os.path.dirname(os.path.realpath(__file__))
DOC_FOLDER = "/mnt/docs"
STRIP_CHARS = len(DOC_FOLDER) + len("file:///")
@ -35,14 +38,14 @@ class Recoll(object):
repo = Recoll()
app = FastAPI()
app.mount("/static", StaticFiles(directory="app/static"))
app.mount("/static", StaticFiles(directory=f"{SQUIRREL_FOLDER}/app/static"))
app.mount("/docs", StaticFiles(directory=DOC_FOLDER))
app.mount(
"/icons",
StaticFiles(directory="/usr/share/icons/breeze/mimetypes/32", follow_symlink=True),
)
templates = Jinja2Templates(directory="app/templates")
templates = Jinja2Templates(directory=f"{SQUIRREL_FOLDER}/app/templates")
@app.get("/")

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB