E
E
EmachinesDIMA2021-11-01 13:21:45
GitLab
EmachinesDIMA, 2021-11-01 13:21:45

What is the correct way to declare artifact persistence with Docker volumes?

1. volumes allows you to create only in the assembly directory.
2. The path on the host for the volume is not created automatically, so I create the ${CI_PROJECT_DIR} directory and specify it as the path for the artifacts.
3. volume contains path : "path_on_host_in_build_folder : path_in_container : read_write_permissions"

4. build passes. the artifact is being created. In quotation marks, because inside the path of the artifact is empty.

0. of and not of the manuals re-read up and down.

I am getting an error:

Uploading artifacts... found 1 matching files and directories ...
Uploading artifacts as "archive" to coordinator... ok id=632087 responseStatus=201 Created token=roSNWzgE
+ exit 0


There is a successful output and supposedly there is an artifact:
Job artifacts
These artifacts are the latest. They will not be deleted (even if expired) until newer artifacts are available.


But there is "empty" ...

--------------------------------- ----

Volume declaration structure:
docker-compose.yml


services:
  app:
    build:
      dockerfile: Dockerfile
      context: .
    volumes:
      - "vlm:/var/www/app:rw"

volumes:
  vlm:
    external:
      name: /var/www/app


.gitlab-ci.yml


upload:
  variables:
    COMPOSE_FILE: docker-compose.yml
    CI_DEBUG_TRACE: "true"
  tags:
    - docker
  stage: upload
  script:
    - echo $CI_JOB_STAGE
    - mkdir -p ${CI_PROJECT_DIR}/tmp/var/www/app
    - docker-compose build --force-rm --no-cache
  artifacts:
    name: "artifact-$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    paths:
      - ${CI_PROJECT_DIR}/tmp/var/www/app
    expire_in: 1h
    when: always
  when:
    manual

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mureevms, 2021-11-01
@EmachinesDIMA

Guess 1:
> Uploading artifacts... found 1 matching files and directories
It found one match. Perhaps this is the directory ${CI_PROJECT_DIR}/tmp/var/www/appin which the file was not found artifact-$CI_JOB_NAME-$CI_COMMIT_REF_NAME. For a solution, try specifying instead of your option, so. It is not clear how and what kind of file is created in this directory, you do not show this, probably it simply does not fit the template.

artifacts:
    when: always
    paths:
      - "${CI_PROJECT_DIR}/tmp/var/www/app/*" # именно в кавычках

Assumption 2: The
runner is run as its user, and the file is created as the user under which the process in the container is launched, as a rule, this is root, so it makes sense to try to give 777 rights to this directory before docker-compose:
script:
    - chmod 777 ${CI_PROJECT_DIR}/tmp/var/www/app

Assumption 3:
Unlikely, you checked, but just in case, check again, confuses the frequent mention of /var/www/app in different variations and is not sure that this is the same directory for the host and container. For example, ${CI_PROJECT_DIR}/tmp/var/www/appa directory for a runner is not the same as for a container.
One last thing :
You mount the directory /var/www/app and create ${CI_PROJECT_DIR}/ tmp /var/www/app

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question