refactor gitlab config

This commit is contained in:
Cyryl Płotnicki 2019-01-20 16:58:41 +00:00
parent 46d91fdf28
commit 923e5f4695

View file

@ -1,4 +1,4 @@
image:fedora: .image:
stage: build stage: build
image: docker:stable image: docker:stable
services: services:
@ -7,32 +7,25 @@ image:fedora:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script: script:
- docker pull $CONTAINER_IMAGE:latest || true - docker pull $CONTAINER_IMAGE:latest || true
- docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_IMAGE:latest ./fedora/ - docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_IMAGE:latest ./$OS_NAME/
- docker push $CONTAINER_IMAGE:$CI_COMMIT_SHA - docker push $CONTAINER_IMAGE:$CI_COMMIT_SHA
- docker push $CONTAINER_IMAGE:latest - docker push $CONTAINER_IMAGE:latest
variables: variables:
DOCKER_HOST: tcp://docker:2375/ DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH/fedora CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH/$OS_NAME
image:fedora:
extends: .image
variables:
OS_NAME: fedora
image:ubuntu: image:ubuntu:
stage: build extends: .image
image: docker:stable
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- docker pull $CONTAINER_IMAGE:latest || true
- docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_IMAGE:latest ./ubuntu/
- docker push $CONTAINER_IMAGE:$CI_COMMIT_SHA
- docker push $CONTAINER_IMAGE:latest
variables: variables:
DOCKER_HOST: tcp://docker:2375/ OS_NAME: ubuntu
DOCKER_DRIVER: overlay2
CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH/ubuntu
fedora: .test:
before_script: before_script:
- apk add bash - apk add bash
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
@ -42,24 +35,24 @@ fedora:
- docker:dind - docker:dind
variables: variables:
DETECTED_OS: fedora:29 DETECTED_OS: fedora:29
DOCKER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH/fedora:latest DOCKER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH/$OS_NAME:$CI_COMMIT_SHA
DOCKER_HOST: tcp://docker:2375/ DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
dependencies: dependencies:
- image:fedora - image:fedora
fedora:
extends: .test
variables:
DETECTED_OS: fedora:29
OS_NAME: fedora
dependencies:
- image:fedora
ubuntu: ubuntu:
before_script: extends: .test
- apk add bash
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script: ./test.sh
image: docker:stable
services:
- docker:dind
variables: variables:
DETECTED_OS: ubuntu:cosmic DETECTED_OS: ubuntu:cosmic
DOCKER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH/ubuntu:latest OS_NAME: ubuntu
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
dependencies: dependencies:
- image:ubuntu - image:ubuntu