I have a Flask application, which uses static files such as 'font.ttf' stored within '/app/static/fonts/' in container directory.
The application functions correctly when running on Python in windows for development, and is able to retrieve the files. However when placed into a Ubuntu Docker container it launches the web-page and basic html, but is unable to serve static files which go with the web-page.
Example error:
GET http://192.168.1.200:5000/static/fonts/Pacifico-Regular.ttf net::ERR_ABORTED 404 (NOT FOUND)
I have the following startup parameters for the flask application.
app = Flask(__name__, static_url_path='', static_folder=os.path.abspath('/app/static/'))
Why is it unable to return the static files?
Reference Folder Structure:
app
├───static
│ ├───css
│ ├───fonts
│ ├───js
│ │ └───lib
│ └───media
└───templates
Dockerfile:
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
RUN apt-get install -y unixodbc-dev
COPY . /app
WORKDIR /app
RUN pip install flask
RUN pip install pyodbc
ENTRYPOINT ["python"]
CMD ["app.py"]
Docker Run:
docker run -d -p 5000:5000 flask-app:latest
Many Thanks