gregseth
gregseth

Reputation: 13408

Gitlab: build docker container, then use it for compilation

Heres my .gitlab-ci.yml

stages:
   - containerize
   - compile

build_image:
  image: docker
  stage: containerize
  script:
    - docker build -t compiler_image_v0 .

compile:
  image: compiler_image_v0
  stage: compile
  script:
    - make
  artifacts:
    when: on_success
    paths:
      - output/
    expire_in: 1 day

The build_image is running correctly, the image created is listed when using the docker images command on the machine with the runners. But the second job fails with the error:

ERROR: Job failed: Error response from daemon: pull access denied for compiler_image_v0, repository does not exist or may require 'docker login' (executor_docker.go:168:1s)

What's going on?

This is my Dockerfile

FROM ubuntu:18.04

WORKDIR /app

# Ubuntu packages
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apt-utils subversion g++ make cmake unzip
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install libgtk2.*common libpango-1* libasound2* xserver-xorg
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install cpio
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install bash
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install autoconf automake perl m4

# Intel Fortran compiler
RUN mkdir /intel
COPY parallel_studio_xe_2018_3_pro_for_docker.zip  /intel
RUN cd /intel && unzip /intel/parallel_studio_xe_2018_3_pro_for_docker.zip
RUN cd /intel/parallel_studio_xe_2018_3_pro_for_docker && ./install.sh --silent=custom_silent.cfg
RUN rm -rf /intel

Upvotes: 1

Views: 1685

Answers (1)

mbuechmann
mbuechmann

Reputation: 5760

The stage compile tries to pull the image compiler_image_v0. This image exists only temporary in the docker container of the stage containerize. You have a container registry in your gitlab repository and can push the built image in the containerize stage and then pull it in the compile stage. Furthermore: You should provide a full name of your private gitlab registry. I think dockerhub is used per default.

You can change your .gitlab.ci.yaml to add the push command and use a fully named image:

stages:
   - containerize
   - compile

build_image:
  image: docker
  stage: containerize
  script:
    - docker build -t compiler_image_v0 .
    - docker push registry.gitlab.com/group-name/repo-name:compiler_image_v0

compile:
  image: registry.gitlab.com/group-name/repo-name:compiler_image_v0
  stage: compile
  script:
    - make
  artifacts:
    when: on_success
    paths:
      - output/
    expire_in: 1 day

This would overwrite the image on each build. But you could add some versioning.

Upvotes: 1

Related Questions