When I host a Flask application in Docker on my PC, the CSS and JS are read correctly from a template and HTML view formatted. When I host the same application in Kubernetes POD, it does not read CSS and JS.
In a snapshot below you can see a result. Below please find a file structure of the app. Views index.html and upload.html are extending public/templates/public_template.html which consists of imports of CSS and JS libraries.
Could you please tell what could be the reason? Could the required file structure be different between kubectl and Docker?
C:.
| .gitignore
| Dockerfile
| upload_app-deploy.yaml
| run.py
|
\---app
| app.py
| requirements.txt
| __init__.py
|
+---static
| +---css
| | bootstrap.min.css
| | style.css
| |
| +---img
| | flask.png
| |
| \---js
| app.js
| bootstrap.bundle.min.js
| jquery.slim.min.js
|
\---templates
+---admin
| \---templates
\---public
| index.html
| upload.html
|
\---templates
public_template.html
Error in the browser:
Failed to load resource: the server responded with a status of 403 ()
jquery.slim.min.js:1 Failed to load resource: the server responded with a status of 403 ()
(index):1 Refused to apply style from 'https://ais-bt-services.asml.com/static/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
app.js:1 Failed to load resource: the server responded with a status of 403 ()
(index):1 Refused to apply style from 'https://ais-bt-services.asml.com/static/css/bootstrap.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Dockerfile:
# Python 3 running on Debian GNU/Linux 10 (buster)(ATM) (amd64)
FROM XXX/docker/python:3
# Fill directories
COPY . /app
# Switch default directory so f.e. you don't have to provide a full pwd of req.txt
WORKDIR /app/app
# Install python packages with fixed versions
RUN pip install --force-reinstall -r requirements.txt
# Execute an app: listener and handler
CMD ["python", "/app/app/app.py"]
Below please find permissions to the catalogues, they seem OK to me, directories to 775 and files to 664 and the root user. Could it be that a user is different once running in Kubernetes? Or maybe any other ideas?