-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
56 lines (56 loc) · 1.96 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
image: docker:stable
services:
- docker:dind
stages:
- linting
- build_and_push
- build_hub
variables:
DOCKER_DRIVER: overlay2
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache"
LATEST_TAG: latest
STRETCH_TAG: stretch
BUSTER_TAG: buster
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:$LATEST_TAG
CONTAINER_STRETCH_IMAGE: $CI_REGISTRY_IMAGE:$STRETCH_TAG
CONTAINER_BUSTER_IMAGE: $CI_REGISTRY_IMAGE:$BUSTER_TAG
HUB_TEST_IMAGE: docker.io/saltman33/ansible-debian
HUB_RELEASE_IMAGE: $HUB_TEST_IMAGE:$LATEST_TAG
HUB_STRETCH_IMAGE: $HUB_TEST_IMAGE:$STRETCH_TAG
HUB_BUSTER_IMAGE: $HUB_TEST_IMAGE:$BUSTER_TAG
cache:
paths:
- .cache/
- venv/
.linting: &linting
stage: linting
dockerfile_lint:
<<: *linting
image: hadolint/hadolint:latest-debian
script:
- hadolint --config .hadolint.yaml ./Dockerfile
build_docker_gitlab:
stage: build_and_push
before_script:
- "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
script:
- docker pull $CONTAINER_RELEASE_IMAGE
- docker build --cache-from $CONTAINER_RELEASE_IMAGE -t $CONTAINER_STRETCH_IMAGE --build-arg VER=$STRETCH_TAG .
- docker build --cache-from $CONTAINER_RELEASE_IMAGE -t $CONTAINER_BUSTER_IMAGE --build-arg VER=$BUSTER_TAG .
- docker push $CONTAINER_STRETCH_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_BUSTER_IMAGE
build_docker_hub:
stage: build_hub
before_script:
- "docker login -u $HUB_USER -p $HUB_PW"
script:
- docker pull $HUB_TEST_IMAGE
- docker build --cache-from $HUB_TEST_IMAGE -t $HUB_STRETCH_IMAGE --build-arg VER=$STRETCH_TAG .
- docker build --cache-from $HUB_TEST_IMAGE -t $HUB_BUSTER_IMAGE --build-arg VER=$BUSTER_TAG .
- docker build --cache-from $HUB_TEST_IMAGE -t $HUB_RELEASE_IMAGE --build-arg VER=$LATEST_TAG .
- docker push $HUB_RELEASE_IMAGE
- docker push $HUB_STRETCH_IMAGE
- docker push $HUB_BUSTER_IMAGE