Skip to content

Commit ca9dcae

Browse files
committed
update
1 parent 69e26d7 commit ca9dcae

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

Webgenie.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+

webgenai/arun.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export UPLOAD_FOLDER="${PROJ_ROOT}/wgupload"
1212

1313
mkdir -p "${UPLOAD_FOLDER}" "${PROJ_ROOT}/wgadmin/nginx"
1414

15-
ln -sfr /opt/webgenai/database/db.sqlite "${PROJ_ROOT}/wgadmin/db.sqlite"
16-
1715
RED='\033[0;31m'
1816
NC='\033[0m' # No Color
1917

@@ -31,8 +29,17 @@ if [[ -z ${APILOGICSERVER_CHATGPT_APIKEY} ]]; then
3129
export APILOGICSERVER_CHATGPT_APIKEY
3230
fi
3331

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
3441
# Kill any running project / set "running" to false
35-
PYTHONPATH=$PWD python database/manager.py -K
42+
python database/manager.py -K
3643

3744
export GUNICORN_CMD_ARGS=" --worker-tmp-dir=/dev/shm -b 0.0.0.0:${APILOGICPROJECT_PORT} --timeout 60 --workers 3 --threads 2 --reload"
3845
gunicorn api_logic_server_run:flask_app

webgenai/database/db.sqlite

0 Bytes
Binary file not shown.

webgenai/database/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import psutil
1515

1616

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
1818

1919
def get_project(project_id: str) -> Project:
2020
"""

webgenai/database/models/project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ def env(self):
251251
Method to return the environment variables for the project
252252
"""
253253
env = os.environ.copy()
254+
if 'SQLALCHEMY_DATABASE_URI' in env:
255+
del env['SQLALCHEMY_DATABASE_URI']
254256
return env | {
255257
"APILOGICPROJECT_SWAGGER_PORT": "8080", #str(self.port),
256258
"APILOGICPROJECT_PORT": str(self.port),

0 commit comments

Comments
 (0)