forked from mrlan/EnglishPal
				
			解决程序源文件更新了,但是 docker container 中的程序源文件没有更新的问题
问题出在 build.sh 中的 --mount type=volume,src=englishpal-db,target=/app 。 运行 docker container 时,会将整个 englishpal-db 对应的文件夹 /var/lib/docker/volumes/englishpal-db/_data 下面的内容拷贝到 docker container 里面的 /app 文件夹下面。 然而,/var/lib/docker/volumes/englishpal-db/_data 下面的源程序文件并不是最新的(比如其 main.py 是 7月17日的)。 将 target=/app 改为 target=/app/db。即可解决问题。Bug511-Bosh
							parent
							
								
									00ae957b27
								
							
						
					
					
						commit
						dca76969eb
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
FROM tiangolo/uwsgi-nginx-flask:python3.8-alpine
 | 
			
		||||
COPY requirements.txt /app
 | 
			
		||||
RUN pip3 install -U pip
 | 
			
		||||
RUN pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
 | 
			
		||||
COPY requirements.txt /tmp
 | 
			
		||||
COPY ./app/ /app/
 | 
			
		||||
RUN pip3 install -U pip -i https://mirrors.aliyun.com/pypi/simple/
 | 
			
		||||
RUN pip3 install -r /tmp/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ from difficulty import get_difficulty_level_for_user, text_difficulty_level, use
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
path_prefix = '/var/www/wordfreq/wordfreq/'
 | 
			
		||||
path_prefix = './'  # comment this line in deployment
 | 
			
		||||
path_prefix = './db/'  # comment this line in deployment
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def total_number_of_essays():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
from pony.orm import *
 | 
			
		||||
 | 
			
		||||
db = Database()
 | 
			
		||||
db.bind("sqlite", "../wordfreqapp.db", create_db=True)  # bind sqlite file
 | 
			
		||||
db.bind("sqlite", "../db/wordfreqapp.db", create_db=True)  # bind sqlite file
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class User(db.Entity):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,6 @@
 | 
			
		|||
  <input type="password" placeholder="密码" class="password"  id="password">
 | 
			
		||||
  <button type="button" class="btn" onclick="login()">登录</button>
 | 
			
		||||
  <a class="signup" href="/signup">注册</a>
 | 
			
		||||
  <label class="form-text">2023-08-10</label>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
{% endif %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,6 +44,7 @@
 | 
			
		|||
                <a href="http://youdao.com/w/eng/{{x[0]}}/#keyfrom=dict2.index">{{x[0]}}</a> {{x[1]}}
 | 
			
		||||
            {% endfor %}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        <p class="text-muted">Version: 20230810</p>
 | 
			
		||||
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{ yml['footer'] | safe }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								build.sh
								
								
								
								
							
							
						
						
									
										5
									
								
								build.sh
								
								
								
								
							| 
						 | 
				
			
			@ -3,9 +3,6 @@
 | 
			
		|||
DEPLOYMENT_DIR=/home/lanhui/englishpal2/EnglishPal
 | 
			
		||||
cd $DEPLOYMENT_DIR
 | 
			
		||||
pwd
 | 
			
		||||
# Install dependencies
 | 
			
		||||
 | 
			
		||||
#pip3 install -r requirements.txt
 | 
			
		||||
 | 
			
		||||
# Stop service
 | 
			
		||||
sudo docker stop EnglishPal
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +12,7 @@ sudo docker rm EnglishPal
 | 
			
		|||
sudo docker build -t englishpal .
 | 
			
		||||
 | 
			
		||||
# Run the application
 | 
			
		||||
sudo docker run --restart=always -d --name EnglishPal -p 90:80 -v ${DEPLOYMENT_DIR}/app/static/frequency:/app/static/frequency --mount type=volume,src=englishpal-db,target=/app -t englishpal  # for permanently saving data
 | 
			
		||||
sudo docker run --restart=always -d --name EnglishPal -p 90:80  -v ${DEPLOYMENT_DIR}/app/static/frequency:/app/static/frequency --mount type=volume,src=englishpal-db,target=/app/db -t englishpal # for permanently saving data
 | 
			
		||||
 | 
			
		||||
# Save space.  Run it after sudo docker run
 | 
			
		||||
sudo docker system prune -a -f
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue