-
Notifications
You must be signed in to change notification settings - Fork 66
/
.gitlab-ci.yml
152 lines (139 loc) · 5.2 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
stages:
- build dev environment
- testing
- build production
cache:
key: "$CI_PIPELINE_ID"
paths:
- /root/.cache
- /root/.npm
- node_modules
- vendor
.before_script_template: &before-script
before_script:
- echo "$CI_BUILD_TOKEN" | docker login -u gitlab-ci-token --password-stdin $REGISTRY_DOMAIN
build-api:
stage: build dev environment
image: docker:stable
<<: *before-script
script:
- cd api
- docker build . --target dev-stage -t $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:api-dev
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:api-dev
- docker build . --target production-stage -t $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:api-latest
build-backend:
stage: build dev environment
image: docker:stable
<<: *before-script
variables:
BASE_URL: /backend/
script:
- cd backend
- docker build . --target build-stage --build-arg NODE_ENV=development --build-arg BASE_URL=/backend/ -t
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:backend-dev
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:backend-dev
- docker build . --target production-stage --build-arg NODE_ENV=production --build-arg BASE_URL=/backend/ -t
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:backend-latest
build-frontend-nuxt:
stage: build dev environment
image: docker:stable
<<: *before-script
variables:
BASE_URL: /frontend-nuxt/
script:
- cd frontend-nuxt
- docker build . --target build-stage --build-arg BASE_URL=/frontend-nuxt/ -t
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-nuxt-dev
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-nuxt-dev
- docker build . --target production-stage --build-arg BASE_URL=/frontend-nuxt/ -t
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-nuxt-latest
build-frontend-vue:
stage: build dev environment
image: docker:stable
<<: *before-script
variables:
BASE_URL: /frontend-vue/
script:
- cd frontend-vue
- docker build . --target build-stage --build-arg NODE_ENV=development --build-arg BASE_URL=/frontend-vue/ -t
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-vue-dev
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-vue-dev
- docker build . --target production-stage --build-arg NODE_ENV=production --build-arg BASE_URL=/frontend-vue/ -t
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-vue-latest
lint-dockerfile:
stage: testing
image: hadolint/hadolint:latest
script:
- hadolint api/Dockerfile
- hadolint backend/Dockerfile
- hadolint frontend-nuxt/Dockerfile
- hadolint frontend-vue/Dockerfile
security-check:
stage: testing
image: aquasec/trivy:latest
<<: *before-script
script:
- trivy image --exit-code 1 -s HIGH,CRITICAL --no-progress
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:api-latest
- trivy image --exit-code 1 -s HIGH,CRITICAL --no-progress
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-nuxt-latest
- trivy image --exit-code 1 -s HIGH,CRITICAL --no-progress
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-vue-latest
- trivy image --exit-code 1 -s HIGH,CRITICAL --no-progress
$REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:backend-latest
testing-and-linting:
stage: testing
image: docker/compose:latest
<<: *before-script
services:
- docker:18-dind
tags:
- dind
variables:
SERVICE_DOMAIN: localhost
script:
- docker-compose -f docker-compose.actions.yml pull
- docker-compose -f docker-compose.actions.yml down -t1 -v --remove-orphans
- docker-compose -f docker-compose.actions.yml up -d
- docker exec api npm run lint
- docker exec api npm run test
- docker exec backend npm run lint
- docker exec backend npm run test:unit
- docker exec backend npm run test:e2e -- --headless
- docker exec frontend-vue npm run lint
- docker exec frontend-vue npm run test:unit
- docker exec frontend-vue npm run test:e2e -- --headless
- docker exec frontend-nuxt npm run test
production-api:
stage: build production
image: docker:stable
<<: *before-script
script:
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:api-latest
production-backend:
stage: build production
image: docker:stable
<<: *before-script
variables:
NODE_ENV: production
BASE_URL: /backend/
script:
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:backend-latest
production-frontend-nuxt:
stage: build production
image: docker:stable
<<: *before-script
variables:
NODE_ENV: production
BASE_URL: /frontend-nuxt/
script:
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-nuxt-latest
production-frontend-vue:
stage: build production
image: docker:stable
<<: *before-script
variables:
NODE_ENV: production
BASE_URL: /frontend-vue/
script:
- docker push $REGISTRY_DOMAIN/chrisleekr/nodejs-vuejs-mysql-boilerplate:frontend-vue-latest