我正在使用bitbucket管道部署我的laravel应用程序,当我将其推送到我的仓库时,它就开始构建,并且可以完美运行,直到docker exec命令将向PHP容器内发送内联命令以执行时,我得到了错误
bash: line 3: docker: command not found
这是非常有线的,因为当我直接在同一目录下的同一台服务器上运行命令时,它运行良好,将docker安装在服务器上,并且您可以在execute.sh内部看到docker-compose可以正常工作,但是当在管道上运行时出现错误,请注意pwd以确保命令在正确的目录中执行。
bitbucket-pipelines.yml
image: php:7.3
pipelines:
branches:
testing:
- step:
name: Deploy to Testing
deployment: Testing
services:
- docker
caches:
- composer
script:
- apt-get update && apt-get install -y unzip openssh-client
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer require phpunit/phpunit
- vendor/bin/phpunit laravel/tests/Unit
- ssh do.server.net 'bash -s' < execute.sh
在execute.sh内部,它看起来像这样:
cd /home/docker/docker-laravel
docker-compose build && docker-compose up -d
pwd
docker exec -ti php sh -c "php helpershell.php"
exit
bitbucket管道构建结果的输出如下所示:
Successfully built 1218483bd067
Successfully tagged docker-laravel_php:latest
Building nginx
Step 1/1 : FROM nginx:latest
---> 4733136e5c3c
Successfully built 4733136e5c3c
Successfully tagged docker-laravel_nginx:latest
Creating php ...
Creating mysql ...
Creating mysql ... done
Creating php ... done
Creating nginx ...
Creating nginx ... done
/home/docker/docker-laravel
bash: line 3: docker: command not found
答案 0 :(得分:0)
我认为发生这种情况的部分原因是因为docker-compose
和docker
是两个单独的命令。仅仅因为一项工作并不意味着它们两者都可以工作。另外,您可能要检查bitbucket-pipelines.yaml
文件的缩进,因为yaml可能很挑剔。
有关示例结构,请参见此处:https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html