0
votes

I am using a self hosted Gitlab-CE Server. I try to use a CI Pipeline with three stages: build, package, deploy

Build is a maven task - that works.

In the package task I try to build the docker container. But this step fails with the following error:

Error response from daemon: Dockerfile parse error line 1: unknown instruction: <!DOCTYPE

That is my .gitlab-ci.yml (Without deploy step)

image: docker:latest
services:
  - docker:dind

variables:
  SPRING_PROFILES_ACTIVE: gitlab-ci

stages:
  - build
  - package
  - deploy

maven-build:
  image: maven:3-jdk-8
  stage: build
  script: "mvn package -B"
  artifacts:
    paths:
      - target/*.jar

docker-build:
  stage: package
  script:
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN https://devel.priv.net
  - docker build -t https://devel.priv.net/d.p/service-discovery
  - docker push https://devel.priv.net/d.p/service-discovery

The gitlab Server can be reached at https://devel.priv.net. The Repository is https://devel.priv.net/d.p/service-discovery It is protected via username and password.

What is wrong in my configuration?

2

2 Answers

0
votes

You should check your /etc/gitlab/gitlab.rb file and search for the registry_external_url configuration variable. You might want to use a subdomain for your GitLab registry or run it on a different port.

registry_external_url "https://registry.devel.priv.net"

The response you get seems to be the HTML code of GitLab's 404 page, because registry is not running on your domain https://devel.priv.net, but docker login tries to login on this url.

You should also try to avoid hard-wiring your registry into .gitlab-ci.yml file and use the CI environment variable $CI_REGISTRY within your docker-build job.

0
votes

Maybe try something like this:

docker-build:
  stage: package
  script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  - docker build -t devel.priv.net/d.p/service-discovery .
  - docker push devel.priv.net/d.p/service-discovery