[英]Execute bash script when running docker-compose in gitlab CI
I've got the following .gitlab-ci.yml
file: 我有以下
.gitlab-ci.yml
文件:
image:
name: docker/compose:1.24.1
entrypoint: ["/bin/sh","-l","-c"]
services:
- docker:dind
stages:
- test
- deploy
pytest:
stage: test
script:
- cd tests/
- docker-compose -f docker-compose.test.yml up --abort-on-container-exit --exit-code-from pytest
which runs the docker-compose.test.yml
file, which looks like this: 运行
docker-compose.test.yml
文件,如下所示:
version: '3'
services:
pytest:
build: ..
command: bash -c "/wait-for-it.sh dynamodb:8000 -- && cd /tests/ && pytest -s"
dynamodb:
image: amazon/dynamodb-local
ports:
- '8000:8000'
command: -jar DynamoDBLocal.jar -inMemory -port 8000
In this case, pytest
waits for dynamodb
to be up and running and then runs the python tests. 在这种情况下,
pytest
等待dynamodb
启动并运行,然后运行python测试。 This works well on my machine. 这在我的机器上运行良好。
However, when Gitlab CI actually runs it, I get the following error: 但是,当Gitlab CI实际运行它时,出现以下错误:
bash: /wait-for-it.sh: Permission denied
How to avoid this issue? 如何避免这个问题? Using
chmod -x
, file is not found. 使用
chmod -x
,找不到文件。
您需要使wait-for-it.sh
可执行文件,在Dockerfile
添加:
RUN chmod +x /path/to/wait-for-it.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.