venv and pip install in dockerfile
This commit is contained in:
parent
2a947d6c7c
commit
b27700ae5c
@ -35,5 +35,7 @@
|
||||
// "remoteUser": "devcontainer"
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash"
|
||||
}
|
||||
},
|
||||
|
||||
"extensions": ["ms-python.python", "dbaeumer.vscode-eslint"]
|
||||
}
|
||||
|
18
.vscode/launch.json
vendored
18
.vscode/launch.json
vendored
@ -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"
|
||||
}
|
||||
|
58
.vscode/tasks.json
vendored
58
.vscode/tasks.json
vendored
@ -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
|
||||
// }
|
||||
// }
|
||||
|
||||
]
|
||||
}
|
12
Dockerfile
12
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
|
||||
|
||||
|
13
agent-py-bot/cmd.sh
Normal file
13
agent-py-bot/cmd.sh
Normal file
@ -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/
|
20
agent-py-bot/requirements.txt
Normal file
20
agent-py-bot/requirements.txt
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user