image: docker:latest
services:
    - docker:dind

default:
  tags:
    - docker
    - isac
    - linux
    
variables:
    NAME: conan-el7-gcc48-x86
    CONTAINER_TEST_IMAGE: ${CI_REGISTRY_IMAGE}/${NAME}:$CI_COMMIT_REF_SLUG
    CONTAINER_RELEASE_IMAGE: ${CI_REGISTRY_IMAGE}/${NAME}:latest
    
stages:
    - build
    - test
    - release

before_script:
    - echo "${CI_JOB_TOKEN}" | docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} --password-stdin

build:
    stage: build
    script:
        - docker build ${DOCKER_BUILD_EXTRA_OPTIONS} --pull -t ${CONTAINER_TEST_IMAGE} -f ${NAME}/Dockerfile .
        - docker push ${CONTAINER_TEST_IMAGE}

test:
    stage: test
    script:
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} cat /etc/centos-release | grep "CentOS Linux release 7"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} uname -m | grep "i686"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} gcc --version | grep "gcc (GCC) 4\.8"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} cmake --version | grep "3.31.5"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} git --version | grep "2.39.2"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} python --version | grep "3.6.13"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} conan --version | grep "2.12.1"
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} jq --version
        - docker run ${DOCKER_RUN_EXTRA_OPTIONS} --rm --platform=linux/386 ${CONTAINER_TEST_IMAGE} yq --version

release:
    stage: release
    script:
        - docker pull ${CONTAINER_TEST_IMAGE}
        - docker tag ${CONTAINER_TEST_IMAGE} ${CONTAINER_RELEASE_IMAGE}
        - docker push ${CONTAINER_RELEASE_IMAGE}
