gpt4 book ai didi

bash - 使用docker-compose run -rm时的前缀

转载 作者:行者123 更新时间:2023-12-02 19:16:52 25 4
gpt4 key购买 nike

我正在使用Laravel开发PHP项目,我的docker-compose中有几个实用程序:

  composer:
image: composer:latest
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
networks:
- laravel

npm:
image: node:13.7
container_name: npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ["npm"]
为此,我必须为每个命令添加 docker-compose run -rm前缀,例如:
docker-compose run -rm npm update
当我在VSCode中的那个项目中时,有没有一种方法可以简单地设置一些别名( npmgruntcomposermysql ...)的环境?

最佳答案

您可以添加task in VS code

Lots of tools exist to automate tasks like linting, building, packaging, testing, or deploying software systems. Examples include the TypeScript Compiler, linters like ESLint and TSLint as well as build systems like Make, Ant, Gulp, Jake, Rake, and MSBuild.


enter image description here
VScode Task
它应该放在 .vscode里面
├── docker-compose.yml
└── .vscode
└── tasks.json

{
"version": "2.0.0",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "docker-compose run ${input:npm}",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "composer",
"type": "shell",
"command": "docker-compose run ${input:compose}",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"inputs": [
{
"id": "npm",
"description": "npm argument:",
"default": "npm",
"type": "promptString"
},
{
"id": "compose",
"description": "compose argument:",
"default": "composer",
"type": "promptString"
}

]
}
现在全部设置,您需要按的
Ctrl + Shift + B,将同时列出两个任务,选择并执行任务。
enter image description here

关于bash - 使用docker-compose run -rm时的前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63033204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com