简体   繁体   中英

Gitlab docker runner problem with path. gitlab-ci.yml

I'm trying to run a pipeline in Gitlab using gitlab-ci.yml file and a runner which can run docker images, but I got an error because the runner cannot find the right path to the Dockerfile

this is my yml file

    image: docker:latest
services:
- docker:dind

stages:
- build
- test
- release

variables:
  TEST_IMAGE: 193.206.43.98:5555/apfeed/apserver:$CI_COMMIT_REF_NAME
  RELEASE_IMAGE: 193.206.43.98:5555/ap:latest

before_script:
  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"

build:
  stage: build
  script:
    - docker build --pull -t $TEST_IMAGE .
    - docker push $TEST_IMAGE

test:
  stage: test
  services:
    - mongo:bionic
  script:
    - docker pull $TEST_IMAGE
    - docker run $TEST_IMAGE npm test

release:
  stage: release
  script:
    - docker pull $TEST_IMAGE
    - docker tag $TEST_IMAGE $RELEASE_IMAGE
    - docker push $RELEASE_IMAGE
  only:

And this is the error I get

 $ docker build --pull -t $TEST_IMAGE .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/gitlab-runner/builds/WsYiLtmC/0/al/apfeed/Dockerfile: no such file or directory
ERROR: Job failed: exit status 1

I tried several different ways of write the path in the line TEST IMAGE but none seems to work

You must have Dockerfile in the project root directory

OR

You can pass the relative path to your Dockerfile if it exists in a subdirectory in the project repo.

eg docker build --pull -t $TEST_IMAGE -f./some-dir/Dockerfile.

some-dir == the directory inside your project repo where Dockerfile is located.

The project repo is first cloned into CI_PROJECT_DIR before each job is executed and CI_PROJECT_DIR is the dir where the.gitlab-ci.yml is gonna exist and the job scripts also run from that directory as well.

https://docs.gitlab.com/ee/ci/variables/README.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM