File tree Expand file tree Collapse file tree 5 files changed +35
-4
lines changed Expand file tree Collapse file tree 5 files changed +35
-4
lines changed Original file line number Diff line number Diff line change
1
+ # Build container
2
+
3
+ ``` bash
4
+ docker build -f docker/webgenie.Dockerfile -t apilogicserver/webgenie --rm .
5
+ ```
6
+
7
+ # Run
8
+ Without persistence (projects are deleted when container shuts down):
9
+
10
+ ``` bash
11
+ docker run -it --rm --name webgenie -p 8080:80 --env-file /opt/webgenai_env apilogicserver/webgenie
12
+ ```
13
+
14
+ The web interface is accessible at http://localhost:8080
15
+
16
+ To keep the projects on the host, mount a writable folder in the container (` /opt/projects ` ):
17
+ ``` bash
18
+ mkdir projects
19
+ chmod 777 projects
20
+ docker run -it --rm --name webgenie -p 8080:80 --env-file /opt/webgenai_env $PWD /projects: apilogicserver/webgenie
21
+ ```
22
+
Original file line number Diff line number Diff line change @@ -12,8 +12,6 @@ export UPLOAD_FOLDER="${PROJ_ROOT}/wgupload"
12
12
13
13
mkdir -p " ${UPLOAD_FOLDER} " " ${PROJ_ROOT} /wgadmin/nginx"
14
14
15
- ln -sfr /opt/webgenai/database/db.sqlite " ${PROJ_ROOT} /wgadmin/db.sqlite"
16
-
17
15
RED=' \033[0;31m'
18
16
NC=' \033[0m' # No Color
19
17
@@ -31,8 +29,17 @@ if [[ -z ${APILOGICSERVER_CHATGPT_APIKEY} ]]; then
31
29
export APILOGICSERVER_CHATGPT_APIKEY
32
30
fi
33
31
32
+ export PYTHONPATH=$PWD
33
+ # Database
34
+ DB_URI=${DB_URI:- " ${PROJ_ROOT} /wgadmin/db.sqlite" }
35
+ export SQLALCHEMY_DATABASE_URI=" sqlite:///${DB_URI} "
36
+ export WG_SQLALCHEMY_DATABASE_URI=" ${SQLALCHEMY_DATABASE_URI} "
37
+ if [[ ! -e " ${DB_URI} " ]]; then
38
+ echo " Creating database at ${DB_URI} "
39
+ python database/manager.py -c
40
+ fi
34
41
# Kill any running project / set "running" to false
35
- PYTHONPATH= $PWD python database/manager.py -K
42
+ python database/manager.py -K
36
43
37
44
export GUNICORN_CMD_ARGS=" --worker-tmp-dir=/dev/shm -b 0.0.0.0:${APILOGICPROJECT_PORT} --timeout 60 --workers 3 --threads 2 --reload"
38
45
gunicorn api_logic_server_run:flask_app
Original file line number Diff line number Diff line change 14
14
import psutil
15
15
16
16
17
- DB_URL = ' sqlite:////opt/webgenai/database/db.sqlite' # TODO, use env var from config
17
+ DB_URL = os . getenv ( 'WG_SQLALCHEMY_DATABASE_URI' , ' sqlite:////opt/webgenai/database/db.sqlite') # TODO, use env var from config
18
18
19
19
def get_project (project_id : str ) -> Project :
20
20
"""
Original file line number Diff line number Diff line change @@ -251,6 +251,8 @@ def env(self):
251
251
Method to return the environment variables for the project
252
252
"""
253
253
env = os .environ .copy ()
254
+ if 'SQLALCHEMY_DATABASE_URI' in env :
255
+ del env ['SQLALCHEMY_DATABASE_URI' ]
254
256
return env | {
255
257
"APILOGICPROJECT_SWAGGER_PORT" : "8080" , #str(self.port),
256
258
"APILOGICPROJECT_PORT" : str (self .port ),
You can’t perform that action at this time.
0 commit comments