Gitlab docker executor - cache image after before_script -


in gitlab-ci there's option in .gitlab-ci.yml file execute commands before of actual script runs, called before_script. .gitlab-ci.yml examples illustrate installing ancillary programs here. however, i've noticed these changes not cached in docker when using docker executor. had naively assumed after running these commands, docker cache image, next run or test, docker load cached image produced after before_script. drastically speed builds.

as example, .gitlab-ci.yml looks little like:

image: ubuntu  before_script:     - apt-get update -qq && apt-get install -yqq make ...  build:     script:         - cd project && make 

a possible solution go runner machine , create docker image can build software without other installation , reference in image section of yaml file. downside of whenever want add dependency, need log in runner machine , update image before builds succeed. nicer if had add dependency to end of apt-get install , have docker / gitlab-ci handle appropriate caching.

there cache command in .gitlab-ci.yml, tried setting untracked: true, thought cache wasn't byproduct of project, didn't seem have effect.

is there way behavior desire?

you can add stage build image in first place. if image doesn't have change, stage short, under 1 second.

you can use image on following stages, speeding whole process.

this example of .gitlab-ci.yml:

stages:   - build_test_image   - test  build_test:   stage: build_test_image   script:     - docker login -u gitlab-ci-token -p $ci_build_token $ci_registry     - docker build -t $ci_registry_image:test -f dockerfiles/test/dockerfile .     - docker push $ci_registry_image:test   tags:     - docker_build  test_syntax:   image: $ci_registry_image:test   stage: test   script:     - pip install flake8     - flake8 --ignore=e501,e265 app/ 

look @ tag docker_build. tag used force execution of stage on runner has tag. executor runner shell, , it's used build docker images. so, host runner lives should have installed docker engine. found solution suits better needs docker in docker , another solutions.

also, i'm using private registry, that's why i'm using $ci_registry* variables, can use dockerhub without need specify registry. problem authenticate on dockerhub, though.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -