From 4078bd63bd5bc42a98c43539ac0faaeef74c99b4 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Thu, 17 Aug 2023 16:05:24 +0800 Subject: [PATCH] db chanage --- appmanage/Dockerfile | 4 +++- appmanage/api/service/db.py | 4 ++-- docker/w9appmanage/docker-compose.yml | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/appmanage/Dockerfile b/appmanage/Dockerfile index 7203b1f2..4c4023f1 100644 --- a/appmanage/Dockerfile +++ b/appmanage/Dockerfile @@ -8,7 +8,9 @@ WORKDIR /usr/src/app # Copy source and install pip dpendencies COPY api ./api COPY static ./static -COPY requirements.txt main.py hostname.py database.sqlite ./ +COPY requirements.txt main.py hostname.py ./ +RUN mkdir /usr/src/app/db +COPY database.sqlite /usr/src/app/db/ RUN apt update # Install supervisord diff --git a/appmanage/api/service/db.py b/appmanage/api/service/db.py index 9d96abca..f020fc34 100644 --- a/appmanage/api/service/db.py +++ b/appmanage/api/service/db.py @@ -12,7 +12,7 @@ def dict_factory(cursor, row): return d def AppUpdateUser(user_name, password): - conn = sqlite3.connect('/usr/src/app/database.sqlite') + conn = sqlite3.connect('/usr/src/app/db/database.sqlite') cursor = conn.cursor() cursor.execute("UPDATE user SET password=? WHERE user_name=?", ( password,user_name,)) conn.commit() @@ -23,7 +23,7 @@ def AppSearchUsers(user_type): raise CommandException(const.ERROR_CLIENT_PARAM_BLANK, "This plugin is blank!", "This plugin is blank!") if user_type != "nginx" and user_type != "portainer": raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "This plugin doesn't exist!", "This plugin doesn't exist!") - conn = sqlite3.connect('/usr/src/app/database.sqlite') + conn = sqlite3.connect('/usr/src/app/db/database.sqlite') conn.row_factory = dict_factory cursor = conn.cursor() cursor.execute("SELECT user_name,password,nick_name FROM user WHERE user_type=?", (user_type,)) diff --git a/docker/w9appmanage/docker-compose.yml b/docker/w9appmanage/docker-compose.yml index 05d57a4c..b6adb8a4 100644 --- a/docker/w9appmanage/docker-compose.yml +++ b/docker/w9appmanage/docker-compose.yml @@ -8,7 +8,8 @@ services: privileged: true restart: unless-stopped volumes: - - appmanage:/usr/src/app + - appmanage-logs:/usr/src/app/logs + - appmanage-db:/usr/src/app/db entrypoint: bash -c "/cmd.sh" ports: - ${APP_HTTP_PORT}:5000 @@ -19,4 +20,5 @@ networks: external: true volumes: - appmanage: + appmanage-logs: + appmanage-db: