Commit 440544f8 authored by Markus Frosch's avatar Markus Frosch
Browse files

Update image.mk to use CI vars

parent 87ac2925
Pipeline #5185 failed with stage
in 2 minutes and 50 seconds
......@@ -5,10 +5,6 @@ services:
stages:
- build
variables:
DOCKER_REGISTRY: ${CI_REGISTRY}
DOCKER_IMAGE_PREFIX: ${CI_PROJECT_PATH}/
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN ${CI_REGISTRY}
......
OS := ubuntu
IMAGE_PREFIX := ${DOCKER_IMAGE_PREFIX}
ifeq ($(IMAGE_PREFIX),)
IMAGE_PREFIX := icinga/ubuntu/
ifndef CI_REGISTRY
CI_REGISTRY := registry.icinga.com
endif
REGISTRY := ${DOCKER_REGISTRY}
ifneq ($(REGISTRY),)
IMAGE_PREFIX := $(REGISTRY)/$(IMAGE_PREFIX)
ifeq ($(CI_PROJECT_PATH),)
CI_PROJECT_PATH := build-docker/ubuntu
endif
FROM := $(shell grep FROM Dockerfile | cut -d" " -f2)
DIST := $(shell basename $$(dirname `pwd`))
VARIANT := $(shell basename `pwd`)
IMAGE := $(IMAGE_PREFIX)$(DIST):$(VARIANT)
IMAGE := $(CI_PROJECT_PATH)/$(DIST)
ifneq ($(CI_REGISTRY),)
IMAGE := $(CI_REGISTRY)/$(IMAGE)
endif
ifeq ($(VARIANT),x86_64)
IMAGE_EXTRA := $(IMAGE_PREFIX)$(DIST):latest
else
IMAGE_EXTRA :=
IMAGE_EXTRA_TAG := latest
endif
all: pull build
pull:
docker pull "$(IMAGE)" || true
docker pull "$(IMAGE):$(VARIANT)" || true
docker pull "$(FROM)"
build:
docker build --cache-from "${IMAGE}" --tag "$(IMAGE)" .
ifneq ($(IMAGE_EXTRA),)
docker tag "$(IMAGE)" "$(IMAGE_EXTRA)"
docker build --cache-from "$(IMAGE):$(VARIANT)" --tag "$(IMAGE):$(VARIANT)" .
ifdef IMAGE_EXTRA_TAG
docker tag "$(IMAGE):$(VARIANT)" "$(IMAGE):$(IMAGE_EXTRA_TAG)"
endif
push:
docker push "$(IMAGE)"
ifneq ($(IMAGE_EXTRA),)
docker push "$(IMAGE_EXTRA)"
ifdef IMAGE_EXTRA_TAG
docker push "$(IMAGE):$(IMAGE_EXTRA_TAG)"
endif
clean:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment