diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d2d547a..0518f2b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -35,5 +35,7 @@ // "remoteUser": "devcontainer" "settings": { "terminal.integrated.shell.linux": "/bin/bash" - } + }, + + "extensions": ["ms-python.python", "dbaeumer.vscode-eslint"] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 6606a9e..eda1824 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,13 +12,25 @@ "platform": "node" }, { - "name": "Docker Python Launch", + "name": "Docker Python Launch?", "type": "python", "request": "launch", "program": "${workspaceFolder}/agent-py-bot/agent.py", "console": "integratedTerminal", - "pythonPath": "${command:python.interpreterPath}", // Assumes Python extension is installed - "preLaunchTask": "docker-run: python-debug", // You may need to create this task + // "python": "${command:python.interpreterPath}", // Assumes Python extension is installed + // "preLaunchTask": "docker-run: python-debug", // You may need to create this task + // "env": { + // "PYTHONUNBUFFERED": "1" + // } + }, + { + "name": "Docker Python Launch with venv", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/agent-py-bot/agent.py", + "console": "integratedTerminal", + "preLaunchTask": "activate-venv", // Custom task to activate venv and run Docker + "python": "/venv/bin/python", // Path to the Python interpreter in your venv "env": { "PYTHONUNBUFFERED": "1" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ece303b..6340b4d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -19,22 +19,22 @@ ], "platform": "node" }, - { - "type": "docker-run", - "label": "docker-run: debug", - "dependsOn": [ - "docker-build" - ], - "dockerRun": { - "env": { - "DEBUG": "*", - "NODE_ENV": "development" - } - }, - "node": { - "enableDebugging": true - } - }, + // { + // "type": "docker-run", + // "label": "docker-run: debug2", + // "dependsOn": [ + // "docker-build" + // ], + // "dockerRun": { + // "env": { + // "DEBUG": "*", + // "NODE_ENV": "development" + // } + // }, + // "node": { + // "enableDebugging": true + // } + // }, { "type": "npm", "script": "start", @@ -45,8 +45,30 @@ { "label": "python-debug", "type": "shell", - "command": "docker exec -w /workspace -it my-python-container /bin/bash -c 'source activate py && python -m debugpy --listen 0.0.0.0:5678 agent-py-bot/agent.py'", + "command": "python -m debugpy --listen 0.0.0.0:5678 agent-py-bot/agent.py", + // "command": "docker exec -w /workspace -it my-python-container /bin/bash -c 'source activate py && python -m debugpy --listen 0.0.0.0:5678 agent-py-bot/agent.py'", "problemMatcher": [] - } + }, + { + "label": "activate-venv-and-run-docker", + "type": "shell", + "command": "source /venv/bin/activate && docker-compose up", // Example command + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + } + // ,{ + // "label": "activate-venv", + // "type": "shell", + // "command": "source /venv/bin/activate", // Example command + // "problemMatcher": [], + // "group": { + // "kind": "build", + // "isDefault": true + // } + // } + ] } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 923755c..0258670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ ENV NODE_ENV=demo RUN apk update && apk add git RUN npm install -g npm@latest + WORKDIR /app COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] # RUN npm install --production --silent @@ -70,6 +71,17 @@ COPY . . RUN npm install EXPOSE 8080 8081 + +# Install Python and pip +RUN apk add --no-cache python3 py3-pip +# If you need Python to be the default version, make a symbolic link to python3 +RUN if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python; fi +# Ensure pip is up to date +#RUN python -m ensurepip --upgrade + +RUN python3 -m venv /venv +RUN . /venv/bin/activate && pip install -r agent-py-bot/requirements.txt + #RUN chown -R node /app #USER node diff --git a/agent-py-bot/cmd.sh b/agent-py-bot/cmd.sh new file mode 100644 index 0000000..877d73b --- /dev/null +++ b/agent-py-bot/cmd.sh @@ -0,0 +1,13 @@ + + +#python -m venv /venv +#! source /venv +. /venv/bin/activate +pip install python-telegram-bot requests selenium Pillow + + +pip install .... + + + +cd agent-py-bot/ diff --git a/agent-py-bot/requirements.txt b/agent-py-bot/requirements.txt new file mode 100644 index 0000000..785cbb7 --- /dev/null +++ b/agent-py-bot/requirements.txt @@ -0,0 +1,20 @@ +anyio==4.2.0 +attrs==23.1.0 +certifi==2023.11.17 +charset-normalizer==3.3.2 +h11==0.14.0 +httpcore==1.0.2 +httpx==0.25.2 +idna==3.6 +outcome==1.3.0.post0 +Pillow==10.1.0 +PySocks==1.7.1 +python-telegram-bot==20.7 +requests==2.31.0 +selenium==4.16.0 +sniffio==1.3.0 +sortedcontainers==2.4.0 +trio==0.23.2 +trio-websocket==0.11.1 +urllib3==2.1.0 +wsproto==1.2.0