Skip to content

Commit 8e08559

Browse files
authored
Merge pull request #56 from dockersamples/add-scheduled-builds
Add scheduled builds
2 parents 15b4c76 + 2a4e652 commit 8e08559

File tree

8 files changed

+441
-186
lines changed

8 files changed

+441
-186
lines changed

.github/workflows/pipeline-docker-cloud.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- '*'
99
pull_request:
1010
workflow_dispatch:
11+
schedule:
12+
- cron: '0 3 5 * *'
1113

1214
jobs:
1315
prettier:

.github/workflows/pipeline-gha.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- '*'
99
pull_request:
1010
workflow_dispatch:
11+
schedule:
12+
- cron: '0 3 5 * *'
1113

1214
jobs:
1315
prettier:

demo/sdlc-e2e-workshop/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SDLC End-to-End demo
2+
3+
This demo is designed to help demonstrate Docker and its value across the entire software development lifecycle (SDLC). Specifically, it allows the demonstrator to:
4+
5+
1. Use a containerized development environment to validate an issue, make code changes, and validate the fix
6+
1. Update integration tests (that use Testcontainers) to validate the code change
7+
1. Demonstrate Testcontainers Cloud's benefits in CI pipelines
8+
1. Build the application with the provided Dockerfile
9+
1. Demonstrate Docker Build Cloud's benefits for building of images, both in local development and in CI pipelines
10+
1. Use Scout to identify issues with the newly built image, including an outdated base image and a library with known vulnerabilities
11+
12+
It does so by purposefully modifying the project to:
13+
14+
1. Remove a field that's published in a Kafka event
15+
1. Downgrade the Dockerfile to an older base image (that has known vulnerabilities)
16+
1. Downgrade an application library (express) to an older version with a known vulnerability
17+
18+
## Demo preparation
19+
20+
Apply the `setup.sh` script (assuming running from this folder):
21+
22+
```console
23+
./setup.sh
24+
```

demo/scout.patch renamed to demo/sdlc-e2e-workshop/demo.patch

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/Dockerfile b/Dockerfile
2-
index 0577738..dc1e81c 100644
2+
index 0577738..87af1b8 100644
33
--- a/Dockerfile
44
+++ b/Dockerfile
55
@@ -5,7 +5,7 @@
@@ -11,36 +11,38 @@ index 0577738..dc1e81c 100644
1111

1212
# Setup a non-root user to run the app
1313
WORKDIR /usr/local/app
14-
@@ -25,7 +25,7 @@ COPY --chown=appuser:appuser package.json package-lock.json ./
14+
@@ -23,7 +23,7 @@ COPY --chown=appuser:appuser package.json package-lock.json ./
15+
# and automatically restart the app.
16+
###########################################################
1517
FROM base AS dev
16-
ENV NODE_ENV=development
18+
-ENV NODE_ENV=development
19+
+ENV NODE_ENV development
1720
RUN npm install
18-
-CMD ["yarn", "dev-container"]
19-
+CMD ["npm", "run", "dev-container"]
20-
21+
CMD ["yarn", "dev-container"]
2122

23+
@@ -35,7 +35,7 @@ CMD ["yarn", "dev-container"]
24+
# installs only the production dependencies.
2225
###########################################################
23-
@@ -41,4 +41,4 @@ COPY ./src ./src
24-
25-
EXPOSE 3000
26+
FROM base AS final
27+
-ENV NODE_ENV=production
28+
+ENV NODE_ENV production
29+
RUN npm ci --production --ignore-scripts && npm cache clean --force
30+
COPY ./src ./src
2631

27-
-CMD [ "node", "src/index.js" ]
28-
\ No newline at end of file
29-
+CMD [ "node", "src/index.js" ]
3032
diff --git a/package-lock.json b/package-lock.json
31-
index d3706f8..0a0c834 100644
33+
index 87fa860..ef8a336 100644
3234
--- a/package-lock.json
3335
+++ b/package-lock.json
3436
@@ -10,7 +10,7 @@
3537
"dependencies": {
3638
"@aws-sdk/client-s3": "^3.651.1",
3739
"dotenv": "^16.4.5",
3840
- "express": "^4.21.1",
39-
+ "express": "4.17.1",
41+
+ "express": "^4.17.1",
4042
"kafkajs": "^2.2.4",
41-
"multer": "^1.4.5-lts.1",
43+
"multer": "^2.0.2",
4244
"node-fetch": "v2",
43-
@@ -3509,27 +3509,24 @@
45+
@@ -3627,27 +3627,24 @@
4446
}
4547
},
4648
"node_modules/body-parser": {
@@ -80,7 +82,7 @@ index d3706f8..0a0c834 100644
8082
}
8183
},
8284
"node_modules/bowser": {
83-
@@ -3678,43 +3675,14 @@
85+
@@ -3796,43 +3793,14 @@
8486
}
8587
},
8688
"node_modules/bytes": {
@@ -127,7 +129,7 @@ index d3706f8..0a0c834 100644
127129
"node_modules/callsites": {
128130
"version": "3.1.0",
129131
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
130-
@@ -4058,17 +4026,23 @@
132+
@@ -4190,17 +4158,23 @@
131133
}
132134
},
133135
"node_modules/content-disposition": {
@@ -155,7 +157,7 @@ index d3706f8..0a0c834 100644
155157
"node_modules/content-type": {
156158
"version": "1.0.5",
157159
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
158-
@@ -4086,9 +4060,9 @@
160+
@@ -4218,9 +4192,9 @@
159161
"license": "MIT"
160162
},
161163
"node_modules/cookie": {
@@ -168,7 +170,7 @@ index d3706f8..0a0c834 100644
168170
"license": "MIT",
169171
"engines": {
170172
"node": ">= 0.6"
171-
@@ -4247,23 +4221,19 @@
173+
@@ -4380,23 +4354,19 @@
172174
}
173175
},
174176
"node_modules/depd": {
@@ -200,7 +202,7 @@ index d3706f8..0a0c834 100644
200202
},
201203
"node_modules/detect-newline": {
202204
"version": "3.1.0",
203-
@@ -4426,20 +4396,6 @@
205+
@@ -4577,20 +4547,6 @@
204206
"url": "https://dotenvx.com"
205207
}
206208
},
@@ -221,7 +223,7 @@ index d3706f8..0a0c834 100644
221223
"node_modules/eastasianwidth": {
222224
"version": "0.2.0",
223225
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
224-
@@ -4481,9 +4437,9 @@
226+
@@ -4632,9 +4588,9 @@
225227
"license": "MIT"
226228
},
227229
"node_modules/encodeurl": {
@@ -234,7 +236,7 @@ index d3706f8..0a0c834 100644
234236
"license": "MIT",
235237
"engines": {
236238
"node": ">= 0.8"
237-
@@ -4549,36 +4505,6 @@
239+
@@ -4700,36 +4656,6 @@
238240
"is-arrayish": "^0.2.1"
239241
}
240242
},
@@ -271,7 +273,7 @@ index d3706f8..0a0c834 100644
271273
"node_modules/escalade": {
272274
"version": "3.2.0",
273275
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
274-
@@ -4706,51 +4632,52 @@
276+
@@ -4857,51 +4783,52 @@
275277
}
276278
},
277279
"node_modules/express": {
@@ -349,7 +351,7 @@ index d3706f8..0a0c834 100644
349351
"node_modules/fast-fifo": {
350352
"version": "1.3.2",
351353
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
352-
@@ -4811,17 +4738,17 @@
354+
@@ -4962,17 +4889,17 @@
353355
}
354356
},
355357
"node_modules/finalhandler": {
@@ -373,15 +375,15 @@ index d3706f8..0a0c834 100644
373375
"unpipe": "~1.0.0"
374376
},
375377
"engines": {
376-
@@ -4923,6 +4850,7 @@
378+
@@ -5074,6 +5001,7 @@
377379
"version": "1.1.2",
378380
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
379381
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
380382
+ "dev": true,
381383
"license": "MIT",
382384
"funding": {
383385
"url": "https://github.com/sponsors/ljharb"
384-
@@ -4961,30 +4889,6 @@
386+
@@ -5112,30 +5040,6 @@
385387
"url": "https://github.com/sponsors/sindresorhus"
386388
}
387389
},
@@ -412,7 +414,7 @@ index d3706f8..0a0c834 100644
412414
"node_modules/get-package-type": {
413415
"version": "0.1.0",
414416
"resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
415-
@@ -5008,19 +4912,6 @@
417+
@@ -5159,19 +5063,6 @@
416418
"url": "https://github.com/sponsors/sindresorhus"
417419
}
418420
},
@@ -432,7 +434,7 @@ index d3706f8..0a0c834 100644
432434
"node_modules/get-stream": {
433435
"version": "6.0.1",
434436
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
435-
@@ -5079,18 +4970,6 @@
437+
@@ -5230,18 +5121,6 @@
436438
"node": ">=4"
437439
}
438440
},
@@ -451,7 +453,7 @@ index d3706f8..0a0c834 100644
451453
"node_modules/graceful-fs": {
452454
"version": "4.2.11",
453455
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
454-
@@ -5108,22 +4987,11 @@
456+
@@ -5259,22 +5138,11 @@
455457
"node": ">=8"
456458
}
457459
},
@@ -475,7 +477,7 @@ index d3706f8..0a0c834 100644
475477
"license": "MIT",
476478
"dependencies": {
477479
"function-bind": "^1.1.2"
478-
@@ -5140,21 +5008,27 @@
480+
@@ -5291,21 +5159,27 @@
479481
"license": "MIT"
480482
},
481483
"node_modules/http-errors": {
@@ -512,7 +514,7 @@ index d3706f8..0a0c834 100644
512514
"node_modules/human-signals": {
513515
"version": "2.1.0",
514516
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
515-
@@ -6641,15 +6515,6 @@
517+
@@ -6807,15 +6681,6 @@
516518
"tmpl": "1.0.5"
517519
}
518520
},
@@ -528,7 +530,7 @@ index d3706f8..0a0c834 100644
528530
"node_modules/media-typer": {
529531
"version": "0.3.0",
530532
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
531-
@@ -6660,13 +6525,10 @@
533+
@@ -6826,13 +6691,10 @@
532534
}
533535
},
534536
"node_modules/merge-descriptors": {
@@ -546,7 +548,7 @@ index d3706f8..0a0c834 100644
546548
},
547549
"node_modules/merge-stream": {
548550
"version": "2.0.0",
549-
@@ -7015,22 +6877,10 @@
551+
@@ -7181,22 +7043,10 @@
550552
"node": ">=0.10.0"
551553
}
552554
},
@@ -572,7 +574,7 @@ index d3706f8..0a0c834 100644
572574
"license": "MIT",
573575
"dependencies": {
574576
"ee-first": "1.1.1"
575-
@@ -7217,9 +7067,9 @@
577+
@@ -7383,9 +7233,9 @@
576578
"license": "ISC"
577579
},
578580
"node_modules/path-to-regexp": {
@@ -585,7 +587,7 @@ index d3706f8..0a0c834 100644
585587
"license": "MIT"
586588
},
587589
"node_modules/pg": {
588-
@@ -7571,18 +7421,12 @@
590+
@@ -7763,18 +7613,12 @@
589591
"license": "MIT"
590592
},
591593
"node_modules/qs": {
@@ -607,7 +609,7 @@ index d3706f8..0a0c834 100644
607609
}
608610
},
609611
"node_modules/queue-tick": {
610-
@@ -7602,13 +7446,13 @@
612+
@@ -7794,13 +7638,13 @@
611613
}
612614
},
613615
"node_modules/raw-body": {
@@ -626,15 +628,15 @@ index d3706f8..0a0c834 100644
626628
"iconv-lite": "0.4.24",
627629
"unpipe": "1.0.0"
628630
},
629-
@@ -7821,6 +7665,7 @@
631+
@@ -8015,6 +7859,7 @@
630632
"version": "5.2.1",
631633
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
632634
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
633635
+ "dev": true,
634636
"funding": [
635637
{
636638
"type": "github",
637-
@@ -7854,63 +7699,54 @@
639+
@@ -8048,63 +7893,54 @@
638640
}
639641
},
640642
"node_modules/send": {
@@ -718,7 +720,7 @@ index d3706f8..0a0c834 100644
718720
"license": "ISC"
719721
},
720722
"node_modules/shebang-command": {
721-
@@ -7936,78 +7772,6 @@
723+
@@ -8130,78 +7966,6 @@
722724
"node": ">=8"
723725
}
724726
},
@@ -797,7 +799,7 @@ index d3706f8..0a0c834 100644
797799
"node_modules/signal-exit": {
798800
"version": "3.0.7",
799801
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
800-
@@ -8186,12 +7950,12 @@
802+
@@ -8380,12 +8144,12 @@
801803
}
802804
},
803805
"node_modules/statuses": {
@@ -814,7 +816,7 @@ index d3706f8..0a0c834 100644
814816
}
815817
},
816818
"node_modules/streamsearch": {
817-
@@ -8560,9 +8324,9 @@
819+
@@ -8754,9 +8518,9 @@
818820
}
819821
},
820822
"node_modules/toidentifier": {
@@ -828,15 +830,27 @@ index d3706f8..0a0c834 100644
828830
"engines": {
829831
"node": ">=0.6"
830832
diff --git a/package.json b/package.json
831-
index 8438638..14bdcf1 100644
833+
index 6da46f4..6df390c 100644
832834
--- a/package.json
833835
+++ b/package.json
834836
@@ -16,7 +16,7 @@
835837
"dependencies": {
836838
"@aws-sdk/client-s3": "^3.651.1",
837839
"dotenv": "^16.4.5",
838840
- "express": "^4.21.1",
839-
+ "express": "4.17.1",
841+
+ "express": "^4.17.1",
840842
"kafkajs": "^2.2.4",
841-
"multer": "^1.4.5-lts.1",
843+
"multer": "^2.0.2",
842844
"node-fetch": "v2",
845+
diff --git a/src/services/ProductService.js b/src/services/ProductService.js
846+
index 31eaed7..a212fd8 100644
847+
--- a/src/services/ProductService.js
848+
+++ b/src/services/ProductService.js
849+
@@ -49,7 +49,6 @@ async function createProduct(product) {
850+
action: "product_created",
851+
id: newProductId,
852+
name: product.name,
853+
- upc: product.upc,
854+
price: product.price,
855+
description: product.description,
856+
});

demo/sdlc-e2e-workshop/setup.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
REPO_ROOT=$(git rev-parse --show-toplevel)
4+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5+
BRANCH_NAME=demo-$(date +%Y%d%m)-$(whoami)
6+
7+
cd "$REPO_ROOT"
8+
9+
echo "==> Setting up branch a demo branch named ${BRANCH_NAME}"
10+
git clean -f
11+
git branch -D temp 2>/dev/null || true
12+
git branch -D $BRANCH_NAME 2>/dev/null || true
13+
git checkout -b temp
14+
git branch -D main
15+
git checkout main
16+
git branch -D temp
17+
git pull
18+
git checkout -b $BRANCH_NAME
19+
20+
echo "==> Applying patch and creating a commit"
21+
git apply --whitespace=fix "${SCRIPT_DIR}/demo.patch"
22+
git commit -am "Demo prep"
23+
24+
echo "==> Installing npm dependencies"
25+
npm install

0 commit comments

Comments
 (0)