venv and pip install in dockerfile
This commit is contained in:
parent
2a947d6c7c
commit
b27700ae5c
@ -35,5 +35,7 @@
|
|||||||
// "remoteUser": "devcontainer"
|
// "remoteUser": "devcontainer"
|
||||||
"settings": {
|
"settings": {
|
||||||
"terminal.integrated.shell.linux": "/bin/bash"
|
"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"
|
"platform": "node"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Docker Python Launch",
|
"name": "Docker Python Launch?",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/agent-py-bot/agent.py",
|
"program": "${workspaceFolder}/agent-py-bot/agent.py",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"pythonPath": "${command:python.interpreterPath}", // Assumes Python extension is installed
|
// "python": "${command:python.interpreterPath}", // Assumes Python extension is installed
|
||||||
"preLaunchTask": "docker-run: python-debug", // You may need to create this task
|
// "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": {
|
"env": {
|
||||||
"PYTHONUNBUFFERED": "1"
|
"PYTHONUNBUFFERED": "1"
|
||||||
}
|
}
|
||||||
|
58
.vscode/tasks.json
vendored
58
.vscode/tasks.json
vendored
@ -19,22 +19,22 @@
|
|||||||
],
|
],
|
||||||
"platform": "node"
|
"platform": "node"
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
"type": "docker-run",
|
// "type": "docker-run",
|
||||||
"label": "docker-run: debug",
|
// "label": "docker-run: debug2",
|
||||||
"dependsOn": [
|
// "dependsOn": [
|
||||||
"docker-build"
|
// "docker-build"
|
||||||
],
|
// ],
|
||||||
"dockerRun": {
|
// "dockerRun": {
|
||||||
"env": {
|
// "env": {
|
||||||
"DEBUG": "*",
|
// "DEBUG": "*",
|
||||||
"NODE_ENV": "development"
|
// "NODE_ENV": "development"
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
"node": {
|
// "node": {
|
||||||
"enableDebugging": true
|
// "enableDebugging": true
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
"type": "npm",
|
"type": "npm",
|
||||||
"script": "start",
|
"script": "start",
|
||||||
@ -45,8 +45,30 @@
|
|||||||
{
|
{
|
||||||
"label": "python-debug",
|
"label": "python-debug",
|
||||||
"type": "shell",
|
"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": []
|
"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 apk update && apk add git
|
||||||
RUN npm install -g npm@latest
|
RUN npm install -g npm@latest
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
|
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
|
||||||
# RUN npm install --production --silent
|
# RUN npm install --production --silent
|
||||||
@ -70,6 +71,17 @@ COPY . .
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
EXPOSE 8080 8081
|
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
|
#RUN chown -R node /app
|
||||||
#USER node
|
#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