I am trying to deploy my python flask code to my Linux
server and I am following the instruction provided in this link and I modified the required files as my project has app.py
and static
and templates
folders. requirements.txt
is already present. here are the contents of modified files:
uwsgi.ini
[uwsgi]
module = app
callable = app
master = true
Dockerfile is same
start.sh
#!/bin/bash
app="docker.test"
docker build -t ${app} .
docker run -d -p 56733:80 \
--name=${app} \
-v $PWD:/app ${app}
and when I open the webpage it does not load properly and images and css code are missing. I deployed it to heroku
and everything works perfectly fine. Can you please help me where am I making a mistake?
Edit: Docker File:
FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7
RUN apk --update add bash nano
ENV STATIC_URL /static
ENV STATIC_PATH /var/www/app/static
COPY ./requirements.txt /var/www/requirements.txt
RUN pip install -r /var/www/requirements.txt
The volume mapping in start.sh seems wrong, the source folder should be mapped to /var/www/ like this
-v $PWD:/var/www/ ${app}
Also your static folder is at the root of your project, in the example it's in an app folder, so either move it to an app folder or fix the ENV instruction like this :
ENV STATIC_PATH /var/www/app/static
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.