.gitlab-ci.yml 1.69 KB
Newer Older
1
image: docker:latest
2 3 4

stages:
    - build
5
    - deploy
6
    - cleanup
David Blyth's avatar
David Blyth committed
7

8
build-image:
9 10
    stage: build
    script:
11 12
        - docker info
        - docker build -t argonneeic/base:job-$CI_PIPELINE_ID --build-arg BUILD_THREADS=20 .
13

14 15
deploy-latest:
    stage: deploy
16
    script:
17
        - sh -c "docker rmi argonneeic/base:latest || :"
18
        - sh -c "docker rmi electronioncollider/anl-base:latest || :"
19
        - docker tag argonneeic/base:job-$CI_PIPELINE_ID argonneeic/base
20
        - docker tag argonneeic/base:job-$CI_PIPELINE_ID electronioncollider/anl-base
21 22
        - docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWD
        - docker push argonneeic/base:latest
23
        - docker push electronioncollider/anl-base:latest
24 25 26
    dependencies: []
    only:
        - master
27

28
deploy-tag:
29 30
    stage: deploy
    script:
31
        - sh -c 'docker rmi argonneeic/base:$CI_COMMIT_REF_NAME || :'
32
        - sh -c 'docker rmi electronioncollider/anl-base:$CI_COMMIT_REF_NAME || :'
33
        - docker tag argonneeic/base:job-$CI_PIPELINE_ID argonneeic/base:$CI_COMMIT_REF_NAME
34
        - docker tag argonneeic/base:job-$CI_PIPELINE_ID electronioncollider/anl-base:$CI_COMMIT_REF_NAME
35 36
        - docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWD
        - docker push argonneeic/base:$CI_COMMIT_REF_NAME
37
        - docker push electronioncollider/anl-base:$CI_COMMIT_REF_NAME
38
    dependencies: []
39
    only:
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        - tags

cleanup-image:
    stage: cleanup
    script:
        - docker rmi argonneeic/base:job-$CI_PIPELINE_ID
    dependencies: []
    when: always

cleanup-containers:
    stage: cleanup
    script:
        - sh -c 'docker rm $(docker ps -qa --no-trunc --filter "status=exited") || :'
    dependencies: []
    when: on_failure