.gitlab-ci.yml 1.23 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 18 19 20 21 22 23
        - sh -c "docker rmi argonneeic/base:latest || :"
        - docker tag argonneeic/base:job-$CI_PIPELINE_ID argonneeic/base
        - docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWD
        - docker push argonneeic/base:latest
    dependencies: []
    only:
        - master
24

25
deploy-tag:
26 27
    stage: deploy
    script:
28 29 30 31 32
        - sh -c 'docker rmi argonneeic/base:$CI_COMMIT_REF_NAME || :'
        - docker tag argonneeic/base:job-$CI_PIPELINE_ID argonneeic/base:$CI_COMMIT_REF_NAME
        - docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWD
        - docker push argonneeic/base:$CI_COMMIT_REF_NAME
    dependencies: []
33
    only:
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        - 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