This repository was archived by the owner on Jan 15, 2025. It is now read-only.
File tree 8 files changed +3387
-106
lines changed
8 files changed +3387
-106
lines changed Original file line number Diff line number Diff line change
1
+ app /.eslintrc.json
2
+ app /test.js
3
+ app /yarn.lock
Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ FROM node:8-alpine
2
2
3
3
WORKDIR /usr/src/app
4
4
5
- ADD ./app/package.json ./app/yarn.lock /usr/src/app/
6
-
7
- RUN yarn install --production && yarn cache clean
8
-
9
5
ADD ./app /usr/src/app/
10
6
11
7
CMD [ "node" , "index.js" ]
Original file line number Diff line number Diff line change @@ -26,12 +26,36 @@ node('jenkins-docker-2') {
26
26
checkout scm
27
27
}
28
28
29
- stage(' Build' ) {
29
+ stage(' Install' ) {
30
+ docker. image(' node:8-alpine' ). inside() {
31
+ sh ' yarn install --development'
32
+ }
33
+ }
34
+
35
+ stage(' Lint' ) {
36
+ docker. image(' node-8-alpine' ). inside() {
37
+ sh ' yarn run lint'
38
+ }
39
+ }
40
+
41
+ stage(' Test' ) {
42
+ docker. image(' node-8-alpine' ). inside() {
43
+ sh ' yarn run test'
44
+ }
45
+ }
46
+
47
+ stage(' Prune' ) {
48
+ docker. image(' node-8-alpine' ). inside() {
49
+ sh ' yarn install --production'
50
+ }
51
+ }
52
+
53
+ stage(' Docker Build' ) {
30
54
conf. DOCKER_IMAGE = " ${ conf.REGISTRY} /${ conf.NAME} :${ conf.TAG} "
31
55
image = docker. build(conf. DOCKER_IMAGE )
32
56
}
33
57
34
- stage(' Push' ) {
58
+ stage(' Docker Push' ) {
35
59
docker. withRegistry(" https://${ conf.REGISTRY} " , conf. REGISTRY ) {
36
60
image. push()
37
61
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends" : " airbnb-base" ,
3
+ "plugins" : [
4
+ " import"
5
+ ]
6
+ }
Original file line number Diff line number Diff line change 1
- const express = require ( 'express' )
2
- const app = express ( )
1
+ const express = require ( 'express' ) ;
3
2
4
- app . get ( '/' , function ( req , res ) {
5
- res . send ( 'Hello World!' )
6
- } )
3
+ const app = express ( ) ;
7
4
8
- app . listen ( 3000 , function ( ) {
9
- console . log ( 'Example app listening on port 3000!' )
10
- } )
5
+ app . get ( '/' , ( req , res ) => res . send ( 'Hello World!' ) ) ;
6
+
7
+ if ( ! module . parent ) {
8
+ // eslint-disable-next-line no-console
9
+ app . listen ( 3000 , ( ) => console . log ( 'Example app listening on port 3000!' ) ) ;
10
+ }
11
+
12
+ module . exports = app ;
Original file line number Diff line number Diff line change 8
8
"license" : " MIT" ,
9
9
"dependencies" : {
10
10
"express" : " ^4.15.3"
11
+ },
12
+ "devDependencies" : {
13
+ "ava" : " ^0.19.1" ,
14
+ "eslint" : " ^4.0.0" ,
15
+ "eslint-config-airbnb-base" : " ^11.2.0" ,
16
+ "eslint-plugin-import" : " ^2.5.0" ,
17
+ "supertest" : " ^3.0.0"
18
+ },
19
+ "scripts" : {
20
+ "test" : " ava" ,
21
+ "lint" : " eslint *.js"
11
22
}
12
23
}
Original file line number Diff line number Diff line change
1
+ import supertest from 'supertest' ;
2
+
3
+ import test from 'ava' ;
4
+
5
+ import app from '.' ;
6
+
7
+ const req = supertest ( app ) ;
8
+
9
+ test ( 'index' , async ( t ) => {
10
+ t . plan ( 2 ) ;
11
+
12
+ const res = await req . get ( '/' ) ;
13
+
14
+ t . is ( res . status , 200 ) ;
15
+ t . is ( res . text , 'Hello World!' ) ;
16
+ } ) ;
You can’t perform that action at this time.
0 commit comments