我的仓库中有这个 docker compose
version: "3.9"
services:
service:
image: <REGISTRIY_LINK_TO_IMG>
platform: linux/x86_64
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
- "8081:8081"
gql-schema-verify:
image: <REGISTRIY_LINK_TO_IMG>
entrypoint: []
volumes:
- ./service/src/main/resources/graphql:/home/node/updated
environment:
- VALIDATED_SERVICE=core
command: /bin/bash validate
这是.gitlab-ci.yml
validate_schema:
services:
- docker:dind
stage: package
image: <REGISTRIY_LINK_TO_IMG>
variables:
DOCKER_IMAGE_NAME: <REGISTRIY_LINK_TO_IMG>
before_script:
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set region $AWS_REGION
- $(aws ecr get-login --region $AWS_REGION --no-include-email)
- echo "AWS login ok"
- echo "Getting the latest short commit hash for API GQL GW"
- apt-get update -y && apt-get install -y jq
script:
- docker-compose -p $DOCKER_IMAGE_TAG up --build -d service
- sh ./docker-build-check.sh "${DOCKER_IMAGE_TAG}_service_1" 70
# Additional debug output
- echo "Listing contents of ./service/src/main/resources/graphql:"
- ls -la ./service/src/main/resources/graphql
# schema check
- docker-compose -p $DOCKER_IMAGE_TAG run --rm verify-gql
after_script: # docker cleanup
- docker-compose -p $DOCKER_IMAGE_TAG rm --stop -v --force
tags:
- internal-docker-dind
不起作用的是,即使
# Additional debug output
显示了正确的文件......
$ ls -la ./service/src/main/resources/graphql
total 24
drwxrwxrwx 2 root root 4096 Feb 23 15:47 .
drwxrwxrwx 5 root root 4096 Feb 15 19:00 ..
-rw-rw-rw- 1 root root 17 Feb 10 18:34 test.graphqls
然而-
/home/node/updated
...它是空的
关于架构检查(脚本中的最后一步)...这是 verify-gql
#!/bin/sh
ls -la /home/node/updated
ls -la 显示空目录:
drwxr-xr-x 2 root root 4096 Feb 23 15:38 .
drwxr-xr-x 1 node node 4096 Feb 23 18:08 ..
知道为什么吗?
由于您使用的是 Bind Mount 而不是 Docker 卷,因此您需要确保正确的权限。
在此可以安装
./service/src/main/resources/graphql
,因此请检查您是否拥有正确的权限。
要进行快速而肮脏的检查,请运行以下命令:
find ./service/src/main/resources/graphql -type d -exec chmod 777 {} \;
find ./service/src/main/resources/graphql -type f -exec chmod 666 {} \;
请注意,您可能需要进一步检查这些权限以尽可能安全。
此外,使用绝对路径插入相对路径会更安全(例如
/home/someuser/service/src/main/resources/graphql
)