forked from BretFisher/node-docker-good-defaults
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
58 lines (54 loc) · 1.39 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
stages:
- validate
- test
- build
validate-files-exist:
stage: validate
image: alpine
script:
#Check if main files exist
- test -f ./Dockerfile
- test -f ./index.js
- test -f ./test/sample.js
- test -f ./docker-compose.yml
- test -f ./kubernetes/ns.yaml
validate-dependencies:
stage: validate
image: alpine
script:
- grep node-docker-good-defaults package.json
unit-tests:
stage: test
image: docker/compose
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
FILE_NAME: test-raport.txt
services:
- docker:dind
script:
- docker version > ${FILE_NAME}
- docker-compose version >> ${FILE_NAME}
- docker-compose up -d
- sleep 10
- docker-compose exec -T node npm test >> ${FILE_NAME}
- docker-compose logs >> ${FILE_NAME}
- docker-compose down
artifacts:
paths:
- ./test-raport.txt
build-and-push-image:
stage: build
image: docker/compose
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_REPO: registry.gitlab.com/filip3kx/node-app-kubernetes
services:
- docker:dind
script:
- docker login registry.gitlab.com --username filip3kx --password $DOCKER_PASS
- docker build -t ${DOCKER_REPO} .
- docker push ${DOCKER_REPO}
- docker build -t "${DOCKER_REPO}:${CI_COMMIT_SHA}" .
- docker push "${DOCKER_REPO}:${CI_COMMIT_SHA}"