feat: refactor tool_code.py to use sys.executable and update Dockerfile for diskcache2 installation
This commit is contained in:
parent
4a6d8c9067
commit
3a91562289
@ -11,7 +11,7 @@ from diskcache import Cache
|
|||||||
from maxkb.const import BASE_DIR
|
from maxkb.const import BASE_DIR
|
||||||
from maxkb.const import PROJECT_DIR
|
from maxkb.const import PROJECT_DIR
|
||||||
|
|
||||||
python_directory = '/opt/maxkb-app/sandbox/py3/bin/python'
|
python_directory = sys.executable
|
||||||
|
|
||||||
|
|
||||||
class ToolExecutor:
|
class ToolExecutor:
|
||||||
@ -45,6 +45,7 @@ try:
|
|||||||
import sys
|
import sys
|
||||||
path_to_exclude = '/opt/py3/lib/python3.11/site-packages'
|
path_to_exclude = '/opt/py3/lib/python3.11/site-packages'
|
||||||
sys.path = [p for p in sys.path if p != path_to_exclude]
|
sys.path = [p for p in sys.path if p != path_to_exclude]
|
||||||
|
sys.path.append('/opt/maxkb-app/sandbox/python-packages')
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
for key in list(env.keys()):
|
for key in list(env.keys()):
|
||||||
if key in os.environ and (key.startswith('MAXKB') or key.startswith('POSTGRES') or key.startswith('PG')):
|
if key in os.environ and (key.startswith('MAXKB') or key.startswith('POSTGRES') or key.startswith('PG')):
|
||||||
@ -93,4 +94,4 @@ except Exception as e:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _exec(_code):
|
def _exec(_code):
|
||||||
return subprocess.run([sys.executable, '-c', _code], text=True, capture_output=True)
|
return subprocess.run([python_directory, '-c', _code], text=True, capture_output=True)
|
||||||
|
|||||||
@ -28,7 +28,9 @@ RUN python3 -m venv /opt/py3 && \
|
|||||||
. /opt/py3/bin/activate && \
|
. /opt/py3/bin/activate && \
|
||||||
if [ "$(uname -m)" = "x86_64" ]; then sed -i 's/^torch.*/torch = {version = "2.7.1+cpu", source = "pytorch"}/g' pyproject.toml; fi && \
|
if [ "$(uname -m)" = "x86_64" ]; then sed -i 's/^torch.*/torch = {version = "2.7.1+cpu", source = "pytorch"}/g' pyproject.toml; fi && \
|
||||||
poetry install && \
|
poetry install && \
|
||||||
export MAXKB_CONFIG_TYPE=ENV && python3 /opt/maxkb-app/apps/manage.py compilemessages
|
export MAXKB_CONFIG_TYPE=ENV && python3 /opt/maxkb-app/apps/manage.py compilemessages && \
|
||||||
|
export PIP_TARGET=/opt/maxkb-app/sandbox/python-packages && \
|
||||||
|
pip install diskcache2 requests pymysql psycopg2-binary
|
||||||
|
|
||||||
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.4
|
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.4
|
||||||
ARG DOCKER_IMAGE_TAG=dev \
|
ARG DOCKER_IMAGE_TAG=dev \
|
||||||
@ -75,10 +77,7 @@ RUN chmod 755 /opt/maxkb-app/installer/*.sh && \
|
|||||||
useradd --no-create-home --home /opt/maxkb-app/sandbox sandbox -g root && \
|
useradd --no-create-home --home /opt/maxkb-app/sandbox sandbox -g root && \
|
||||||
chown -R sandbox:root /opt/maxkb-app/sandbox && \
|
chown -R sandbox:root /opt/maxkb-app/sandbox && \
|
||||||
chmod g-x /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/17/bin/* && \
|
chmod g-x /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/17/bin/* && \
|
||||||
chmod g+x /usr/local/bin/python* && \
|
chmod g+x /usr/local/bin/python*
|
||||||
python3 -m venv /opt/maxkb-app/sandbox/py3 && \
|
|
||||||
. /opt/maxkb-app/sandbox/py3/bin/activate && \
|
|
||||||
/opt/maxkb-app/sandbox/py3/bin/pip install diskcache2
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
VOLUME /opt/maxkb
|
VOLUME /opt/maxkb
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user