-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
98 lines (87 loc) · 2.26 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# see https://docs.gitlab.com/ce/ci/yaml/README.html for all available options
# Docker-in-Docker
image:
name: docker/compose:1.24.1
entrypoint: ["sh", "-c"]
services:
- name: docker:19.03.12-dind
alias: docker
variables:
VARIANT: alpine
DOCKER_REPO: monogramm/spring-rest-api-starter
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
# This instructs Docker NOT to start over TLS.
DOCKER_TLS_CERTDIR: ""
# This instructs Docker to start over TLS.
#DOCKER_TLS_CERTDIR: "/certs"
# Check docker
before_script:
- pwd
- id
- apk add bash git
- docker --version
- docker-compose --version
- docker info
# Always cleanup after the build
after_script:
- docker images
- docker image prune -f --filter until=$(TZ=EST+24 date +%Y-%m-%d)
# Execute CI build hooks
build-hooks:
stage: build
tags:
- docker
coverage: '/Total.*?([0-9]{1,3})%/'
script:
# Export variables to tag against GitLab Registry
#- [ -z "${CI_REGISTRY_IMAGE}" ] || export DOCKER_REPO=${$CI_REGISTRY_IMAGE}
- ./hooks/run build "${VARIANT}"
# Save docker image as artifact
- mkdir -p .docker/image
- docker save "${DOCKER_REGISTRY}/${DOCKER_REPO}:${VARIANT}" > .docker/image/app.tar
- ls -al .docker/image/app.tar
artifacts:
expire_in: 24 hrs
paths:
- .docker/image
# Execute CI test hooks
test-hooks:
stage: test
tags:
- docker
script:
# Load artifact from build stage
- docker load -i .docker/image/app.tar
- ./hooks/run test "${VARIANT}"
# Publish images
#push-hooks:
# stage: deploy
# tags:
# - docker
# script:
# # Export variables to login and push to GitLab Registry
# - [ -z "${CI_REGISTRY_IMAGE}" ] || export DOCKER_LOGIN=${CI_REGISTRY_USER}
# - [ -z "${CI_REGISTRY_IMAGE}" ] || export DOCKER_PASSWORD=${CI_REGISTRY_PASSWORD}
# - [ -z "${CI_REGISTRY_IMAGE}" ] || export DOCKER_REGISTRY=${CI_REGISTRY}
# # Load artifact from build stage
# - docker load -i .docker/image/app.tar
# - ./hooks/run push
# Publish test results
#push-coverage:
# stage: deploy
# script:
# - echo "TBD"
# Deploy to stage
#staging:
# stage: staging
# script:
# - echo "TBD"
# Deploy to production
#production:
# stage: production
# script:
# - echo "TBD"
# when: manual
# only:
# - master