Sen*_*ihl 7 gitlab docker-compose
我尝试将Gitlab CI与docker-compose结合使用,但总是收到此错误:
$ docker-compose up -d --build
Creating network "backoffice_default" with the default driver
Building php
Creating backoffice_database_1 ...
Creating backoffice_database_1 ... done
Creating backoffice_php_1 ...
Creating backoffice_php_1 ... done
$ docker-compose exec php composer -v
Traceback (most recent call last):
File "bin/docker-compose", line 6, in <module>
File "compose/cli/main.py", line 68, in main
File "compose/cli/main.py", line 121, in perform_command
File "compose/cli/main.py", line 464, in exec_command
File "site-packages/dockerpty/pty.py", line 338, in start
File "site-packages/dockerpty/io.py", line 32, in set_blocking
ValueError: file descriptor cannot be a negative integer (-1)
Failed to execute script docker-compose
Run Code Online (Sandbox Code Playgroud)
我将 docker 与shellrunner 一起使用,如下所示:
[[runners]]
name = "direct runner"
url = MY_GITLAB_URL
token = REPO_GITLAB_TOKEN
executor = "shell"
[runners.cache]
Run Code Online (Sandbox Code Playgroud)
这是我的docker-compose.yml文件:
version: '2'
services:
database:
image: mysql:latest
environment:
MYSQL_DATABASE: database
MYSQL_ROOT_PASSWORD: mysql_strong_password
MYSQL_USER: database
MYSQL_PASSWORD: mysql_strong_password
php:
build: ./app/docker
tty: true
volumes:
- ./app/docker/php.ini:/usr/local/etc/php/conf.d/custom.ini
- ./:/var/www/symfony
links:
- database
Run Code Online (Sandbox Code Playgroud)
这是我的.gitlab-ci.yml
stages:
- build
- cleanup_build
- test
- deploy
- cleanup
before_script:
- docker info
build:
stage: build
script:
- docker-compose up -d --build
- docker-compose exec php composer -v
- docker-compose exec php composer install
- docker-compose exec php php bin/console doctrine:schema:create --dump-sql --force
- docker-compose exec php php bin/console doctrine:fixtures:load -n
cleanup_build:
stage: cleanup_build
script:
- docker-compose config
- docker-compose ps
- docker-compose logs php
- docker-compose logs database
- exit 1
when: on_failure
phpunit:
stage: test
script:
- docker-compose exec -T php phpunit -c .
deploy:
stage: deploy
script:
- echo "deploy to staging server"
cleanup:
stage: cleanup
script:
- docker-compose down
Run Code Online (Sandbox Code Playgroud)
你们知道如何解决这个问题吗?因为我直接从 shell 使用gitlab-runner用户尝试并执行相同的命令,所以没有任何错误。我尝试使用该docker-compose exec标志运行-T,但出现另一个错误:ERROR: Job failed: exit status 1没有附加消息
| 归档时间: |
|
| 查看次数: |
1352 次 |
| 最近记录: |