alessandro trinca tornidor commited on
Commit
acec8bf
·
1 Parent(s): 3bd20e4

[refactor] add FASTAPI_STATIC folder under ${XDG_CACHE_HOME}/static

Browse files
Files changed (2) hide show
  1. app.py +4 -2
  2. scripts/entrypoint.sh +4 -0
app.py CHANGED
@@ -28,8 +28,10 @@ from utils.utils import (DEFAULT_IM_END_TOKEN, DEFAULT_IM_START_TOKEN,
28
 
29
  CUSTOM_GRADIO_PATH = "/gradio"
30
  app = FastAPI()
31
- os.makedirs("static", exist_ok=True)
32
- app.mount("/static", StaticFiles(directory="static"), name="static")
 
 
33
  templates = Jinja2Templates(directory="templates")
34
 
35
 
 
28
 
29
  CUSTOM_GRADIO_PATH = "/gradio"
30
  app = FastAPI()
31
+
32
+ FASTAPI_STATIC = os.getenv("FASTAPI_STATIC")
33
+ os.makedirs(FASTAPI_STATIC, exist_ok=True)
34
+ app.mount("/static", StaticFiles(directory=FASTAPI_STATIC), name="static")
35
  templates = Jinja2Templates(directory="templates")
36
 
37
 
scripts/entrypoint.sh CHANGED
@@ -4,6 +4,7 @@ WORKDIR="/var/task"
4
  XDG_CACHE_HOME="/data"
5
  MPLCONFIGDIR=${XDG_CACHE_HOME}/.cache/matplotlib
6
  TRANSFORMERS_CACHE=${XDG_CACHE_HOME}/.cache/transformers
 
7
 
8
  ls -ld ${XDG_CACHE_HOME}/
9
  ls -l ${XDG_CACHE_HOME}/
@@ -12,6 +13,8 @@ mkdir -p ${XDG_CACHE_HOME}/.cache
12
  chmod 770 -R ${XDG_CACHE_HOME}/.cache
13
  mkdir -p ${MPLCONFIGDIR}
14
  mkdir -p ${TRANSFORMERS_CACHE}
 
 
15
 
16
  ls -ld ${XDG_CACHE_HOME}/
17
  ls -l ${XDG_CACHE_HOME}/
@@ -19,6 +22,7 @@ export WORKDIR
19
  export XDG_CACHE_HOME
20
  export MPLCONFIGDIR
21
  export TRANSFORMERS_CACHE
 
22
 
23
  source ${WORKDIR}/venv/bin/activate
24
 
 
4
  XDG_CACHE_HOME="/data"
5
  MPLCONFIGDIR=${XDG_CACHE_HOME}/.cache/matplotlib
6
  TRANSFORMERS_CACHE=${XDG_CACHE_HOME}/.cache/transformers
7
+ FASTAPI_STATIC=${XDG_CACHE_HOME}/static
8
 
9
  ls -ld ${XDG_CACHE_HOME}/
10
  ls -l ${XDG_CACHE_HOME}/
 
13
  chmod 770 -R ${XDG_CACHE_HOME}/.cache
14
  mkdir -p ${MPLCONFIGDIR}
15
  mkdir -p ${TRANSFORMERS_CACHE}
16
+ mkdir -p ${FASTAPI_STATIC}
17
+ chmod 770 -R ${FASTAPI_STATIC}
18
 
19
  ls -ld ${XDG_CACHE_HOME}/
20
  ls -l ${XDG_CACHE_HOME}/
 
22
  export XDG_CACHE_HOME
23
  export MPLCONFIGDIR
24
  export TRANSFORMERS_CACHE
25
+ export FASTAPI_STATIC
26
 
27
  source ${WORKDIR}/venv/bin/activate
28