From 08510ae883ca234c59c672efb87bcc7aa8492e3a Mon Sep 17 00:00:00 2001 From: sid palas Date: Fri, 27 Jan 2023 09:26:02 -0500 Subject: [PATCH] restructure repo, separate sample app from docker configs --- 04-using-3rd-party-containers/README.md | 0 05-example-web-application/Makefile | 31 ++ 05-example-web-application/README.md | 16 + .../api-golang/.dockerignore | 0 .../api-golang/Makefile | 0 .../api-golang/README.md | 0 .../api-golang/database/db.go | 0 .../api-golang/go.mod | 0 .../api-golang/go.sum | 0 .../api-golang/main.go | 0 .../api-golang/nohup.out | 94 ++++ .../api-node/.dockerignore | 0 .../api-node/Makefile | 0 .../api-node/README.md | 0 .../api-node/package-lock.json | 419 ++++++++++++++++++ .../api-node/package.json | 5 + .../api-node/src/db.js | 0 .../api-node/src/index.js | 4 + .../client-react/.dockerignore | 0 .../client-react/.gitignore | 0 .../client-react/README.md | 0 .../client-react/index.html | 0 .../client-react/nginx.conf | 0 .../client-react/package-lock.json | 0 .../client-react/package.json | 0 .../client-react/public/favicon.ico | Bin .../client-react/src/App.css | 0 .../client-react/src/App.jsx | 0 .../client-react/src/index.css | 0 .../client-react/src/main.jsx | 0 .../client-react/vite.config.js | 26 ++ .../Makefile | 4 - .../api-golang/Dockerfile.0 | 0 .../api-golang/Dockerfile.1 | 0 .../api-golang/Dockerfile.2 | 0 .../api-golang/Dockerfile.3 | 0 .../api-golang/Dockerfile.4 | 0 .../api-golang/Dockerfile.5 | 0 .../api-golang/Dockerfile.6 | 0 .../api-golang/Makefile | 12 + .../api-node/Dockerfile.0 | 0 .../api-node/Dockerfile.1 | 0 .../api-node/Dockerfile.2 | 0 .../api-node/Dockerfile.3 | 0 .../api-node/Dockerfile.4 | 0 .../api-node/Dockerfile.5 | 0 .../api-node/Dockerfile.6 | 0 .../api-node/Dockerfile.7 | 0 .../api-node/Makefile | 12 + .../client-react/Dockerfile | 0 .../client-react/Dockerfile.0 | 0 .../client-react/Dockerfile.1 | 0 .../client-react/Dockerfile.2 | 0 .../client-react/Dockerfile.3 | 4 + .../client-react/Makefile | 12 + .../client-react/vite.config.js | 0 .../docker-compose.yml | 18 +- .../sample-dockerfiles/Dockerfile | 0 58 files changed, 645 insertions(+), 12 deletions(-) create mode 100644 04-using-3rd-party-containers/README.md create mode 100644 05-example-web-application/Makefile create mode 100644 05-example-web-application/README.md rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/.dockerignore (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/Makefile (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/README.md (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/database/db.go (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/go.mod (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/go.sum (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-golang/main.go (100%) create mode 100644 05-example-web-application/api-golang/nohup.out rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/.dockerignore (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/Makefile (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/README.md (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/package-lock.json (64%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/package.json (73%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/src/db.js (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/api-node/src/index.js (86%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/.dockerignore (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/.gitignore (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/README.md (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/index.html (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/nginx.conf (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/package-lock.json (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/package.json (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/public/favicon.ico (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/src/App.css (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/src/App.jsx (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/src/index.css (100%) rename {04-building-container-images/sample-app => 05-example-web-application}/client-react/src/main.jsx (100%) create mode 100644 05-example-web-application/client-react/vite.config.js rename {04-building-container-images/sample-app => 06-building-container-images}/Makefile (79%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.0 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.1 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.2 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.3 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.4 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.5 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-golang/Dockerfile.6 (100%) create mode 100644 06-building-container-images/api-golang/Makefile rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.0 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.1 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.2 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.3 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.4 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.5 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.6 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/api-node/Dockerfile.7 (100%) create mode 100644 06-building-container-images/api-node/Makefile rename {04-building-container-images/sample-app => 06-building-container-images}/client-react/Dockerfile (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/client-react/Dockerfile.0 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/client-react/Dockerfile.1 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/client-react/Dockerfile.2 (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/client-react/Dockerfile.3 (85%) create mode 100644 06-building-container-images/client-react/Makefile rename {04-building-container-images/sample-app => 06-building-container-images}/client-react/vite.config.js (100%) rename {04-building-container-images/sample-app => 06-building-container-images}/docker-compose.yml (52%) rename {04-building-container-images => 06-building-container-images}/sample-dockerfiles/Dockerfile (100%) diff --git a/04-using-3rd-party-containers/README.md b/04-using-3rd-party-containers/README.md new file mode 100644 index 0000000..e69de29 diff --git a/05-example-web-application/Makefile b/05-example-web-application/Makefile new file mode 100644 index 0000000..ff8c348 --- /dev/null +++ b/05-example-web-application/Makefile @@ -0,0 +1,31 @@ +.PHONY: run-postgres +run-postgres: + @echo Starting postgres container + -docker run \ + -e POSTGRES_PASSWORD=foobarbaz \ + -p 5432:5432 \ + postgres:15.1-alpine + +.PHONY: run-api-node +run-api-node: + @echo Starting node api + cd api-node && \ + PGUSER=postgres \ + PGHOST=localhost \ + PGPASSWORD=foobarbaz \ + PGDATABASE=postgres \ + PGPORT=5432 \ + npm run dev + +.PHONY: run-api-golang +run-api-golang: + @echo Starting golang api + cd api-golang && \ + DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \ + go run main.go + +.PHONY: run-client-react +run-client-react: + @echo Starting react client + cd client-react && \ + npm run dev diff --git a/05-example-web-application/README.md b/05-example-web-application/README.md new file mode 100644 index 0000000..1c9dbc4 --- /dev/null +++ b/05-example-web-application/README.md @@ -0,0 +1,16 @@ +Docker Desktop: https://docs.docker.com/get-docker/ + +Docker Engine: https://get.docker.com/ + +Hello World: +``` +docker run docker/whalesay cowsay "Hey Team! 👋" +``` + +Run Postgres: +``` +docker run \ + --env POSTGRES_PASSWORD=foobarbaz \ + --publish 5432:5432 \ + postgres:15.1-alpine +``` \ No newline at end of file diff --git a/04-building-container-images/sample-app/api-golang/.dockerignore b/05-example-web-application/api-golang/.dockerignore similarity index 100% rename from 04-building-container-images/sample-app/api-golang/.dockerignore rename to 05-example-web-application/api-golang/.dockerignore diff --git a/04-building-container-images/sample-app/api-golang/Makefile b/05-example-web-application/api-golang/Makefile similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Makefile rename to 05-example-web-application/api-golang/Makefile diff --git a/04-building-container-images/sample-app/api-golang/README.md b/05-example-web-application/api-golang/README.md similarity index 100% rename from 04-building-container-images/sample-app/api-golang/README.md rename to 05-example-web-application/api-golang/README.md diff --git a/04-building-container-images/sample-app/api-golang/database/db.go b/05-example-web-application/api-golang/database/db.go similarity index 100% rename from 04-building-container-images/sample-app/api-golang/database/db.go rename to 05-example-web-application/api-golang/database/db.go diff --git a/04-building-container-images/sample-app/api-golang/go.mod b/05-example-web-application/api-golang/go.mod similarity index 100% rename from 04-building-container-images/sample-app/api-golang/go.mod rename to 05-example-web-application/api-golang/go.mod diff --git a/04-building-container-images/sample-app/api-golang/go.sum b/05-example-web-application/api-golang/go.sum similarity index 100% rename from 04-building-container-images/sample-app/api-golang/go.sum rename to 05-example-web-application/api-golang/go.sum diff --git a/04-building-container-images/sample-app/api-golang/main.go b/05-example-web-application/api-golang/main.go similarity index 100% rename from 04-building-container-images/sample-app/api-golang/main.go rename to 05-example-web-application/api-golang/main.go diff --git a/05-example-web-application/api-golang/nohup.out b/05-example-web-application/api-golang/nohup.out new file mode 100644 index 0000000..466d878 --- /dev/null +++ b/05-example-web-application/api-golang/nohup.out @@ -0,0 +1,94 @@ +2023/01/27 08:34:41 DATABASE CONNECTED 🥇 +[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. + +[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. + - using env: export GIN_MODE=release + - using code: gin.SetMode(gin.ReleaseMode) + +[GIN-debug] GET / --> main.main.func1 (3 handlers) +[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. +Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. +[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default +[GIN-debug] Listening and serving HTTP on :8080 +QueryRow failed: failed to connect to `host=db user=postgres database=postgres`: hostname resolving error (lookup db: no such host) +exit status 1 +2023/01/27 08:36:16 DATABASE CONNECTED 🥇 +[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. + +[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. + - using env: export GIN_MODE=release + - using code: gin.SetMode(gin.ReleaseMode) + +[GIN-debug] GET / --> main.main.func1 (3 handlers) +[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. +Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. +[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default +[GIN-debug] Listening and serving HTTP on :8080 +[GIN] 2023/01/27 - 08:36:20 | 200 | 76.361836ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:20 | 404 | 551ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:20 | 200 | 2.305566ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:21 | 404 | 584ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:21 | 200 | 2.258435ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:21 | 404 | 494ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:21 | 200 | 1.808336ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:21 | 404 | 530ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:21 | 200 | 1.571416ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:21 | 404 | 599ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:21 | 200 | 1.787527ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:21 | 404 | 657ns | ::1 | GET "/favicon.ico" +2023/01/27 08:36:24 DATABASE CONNECTED 🥇 +[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. + +[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. + - using env: export GIN_MODE=release + - using code: gin.SetMode(gin.ReleaseMode) + +[GIN-debug] GET / --> main.main.func1 (3 handlers) +[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. +Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. +[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default +[GIN-debug] Listening and serving HTTP on :8080 +[GIN-debug] [ERROR] listen tcp :8080: bind: address already in use +[GIN] 2023/01/27 - 08:36:28 | 200 | 1.946844ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:28 | 404 | 828ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:28 | 200 | 1.60934ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:28 | 404 | 537ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:29 | 200 | 1.96418ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:29 | 404 | 519ns | ::1 | GET "/favicon.ico" +[GIN] 2023/01/27 - 08:36:29 | 200 | 1.956822ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:36:29 | 404 | 554ns | ::1 | GET "/favicon.ico" +2023/01/27 08:39:10 DATABASE CONNECTED 🥇 +[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. + +[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. + - using env: export GIN_MODE=release + - using code: gin.SetMode(gin.ReleaseMode) + +[GIN-debug] GET / --> main.main.func1 (3 handlers) +[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. +Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. +[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default +[GIN-debug] Listening and serving HTTP on :8080 +[GIN-debug] [ERROR] listen tcp :8080: bind: address already in use +2023/01/27 08:39:21 DATABASE CONNECTED 🥇 +[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. + +[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. + - using env: export GIN_MODE=release + - using code: gin.SetMode(gin.ReleaseMode) + +[GIN-debug] GET / --> main.main.func1 (3 handlers) +[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. +Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. +[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default +[GIN-debug] Listening and serving HTTP on :8080 +[GIN-debug] [ERROR] listen tcp :8080: bind: address already in use +[GIN] 2023/01/27 - 08:39:29 | 200 | 2.692438ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:30 | 200 | 2.633877ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:31 | 200 | 2.567795ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:31 | 200 | 3.106938ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:32 | 200 | 3.875721ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:32 | 200 | 2.054595ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:32 | 200 | 3.713489ms | ::1 | GET "/" +[GIN] 2023/01/27 - 08:39:32 | 200 | 1.914952ms | ::1 | GET "/" +signal: terminated diff --git a/04-building-container-images/sample-app/api-node/.dockerignore b/05-example-web-application/api-node/.dockerignore similarity index 100% rename from 04-building-container-images/sample-app/api-node/.dockerignore rename to 05-example-web-application/api-node/.dockerignore diff --git a/04-building-container-images/sample-app/api-node/Makefile b/05-example-web-application/api-node/Makefile similarity index 100% rename from 04-building-container-images/sample-app/api-node/Makefile rename to 05-example-web-application/api-node/Makefile diff --git a/04-building-container-images/sample-app/api-node/README.md b/05-example-web-application/api-node/README.md similarity index 100% rename from 04-building-container-images/sample-app/api-node/README.md rename to 05-example-web-application/api-node/README.md diff --git a/04-building-container-images/sample-app/api-node/package-lock.json b/05-example-web-application/api-node/package-lock.json similarity index 64% rename from 04-building-container-images/sample-app/api-node/package-lock.json rename to 05-example-web-application/api-node/package-lock.json index 6cd38d4..716f469 100644 --- a/04-building-container-images/sample-app/api-node/package-lock.json +++ b/05-example-web-application/api-node/package-lock.json @@ -10,9 +10,19 @@ "license": "ISC", "dependencies": { "express": "^4.18.2", + "morgan": "^1.10.0", "pg": "^8.8.0" + }, + "devDependencies": { + "nodemon": "^2.0.20" } }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -25,11 +35,55 @@ "node": ">= 0.6" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/basic-auth/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -53,6 +107,28 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/buffer-writer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", @@ -81,6 +157,39 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -205,6 +314,18 @@ "node": ">= 0.10.0" } }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -238,6 +359,20 @@ "node": ">= 0.6" } }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -256,6 +391,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -267,6 +414,15 @@ "node": ">= 0.4.0" } }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -304,6 +460,12 @@ "node": ">=0.10.0" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -317,6 +479,48 @@ "node": ">= 0.10" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -368,6 +572,44 @@ "node": ">= 0.6" } }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/morgan": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", + "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", + "dependencies": { + "basic-auth": "~2.0.1", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-finished": "~2.3.0", + "on-headers": "~1.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/morgan/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -381,6 +623,73 @@ "node": ">= 0.6" } }, + "node_modules/nodemon": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", + "integrity": "sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^5.7.1", + "simple-update-notifier": "^1.0.7", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=8.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-inspect": { "version": "1.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", @@ -400,6 +709,14 @@ "node": ">= 0.8" } }, + "node_modules/on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/packet-reader": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", @@ -492,6 +809,18 @@ "split2": "^4.1.0" } }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/postgres-array": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", @@ -539,6 +868,12 @@ "node": ">= 0.10" } }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -575,6 +910,18 @@ "node": ">= 0.8" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -599,6 +946,15 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -659,6 +1015,27 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/simple-update-notifier": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", + "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "dev": true, + "dependencies": { + "semver": "~7.0.0" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/simple-update-notifier/node_modules/semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/split2": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", @@ -675,6 +1052,30 @@ "node": ">= 0.8" } }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -683,6 +1084,18 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "dependencies": { + "nopt": "~1.0.10" + }, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -695,6 +1108,12 @@ "node": ">= 0.6" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/04-building-container-images/sample-app/api-node/package.json b/05-example-web-application/api-node/package.json similarity index 73% rename from 04-building-container-images/sample-app/api-node/package.json rename to 05-example-web-application/api-node/package.json index 797ce13..6585cc0 100644 --- a/04-building-container-images/sample-app/api-node/package.json +++ b/05-example-web-application/api-node/package.json @@ -4,12 +4,17 @@ "description": "simple api that connects to postgres", "main": "src/index.js", "scripts": { + "dev": "nodemon src/index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.18.2", + "morgan": "^1.10.0", "pg": "^8.8.0" + }, + "devDependencies": { + "nodemon": "^2.0.20" } } diff --git a/04-building-container-images/sample-app/api-node/src/db.js b/05-example-web-application/api-node/src/db.js similarity index 100% rename from 04-building-container-images/sample-app/api-node/src/db.js rename to 05-example-web-application/api-node/src/db.js diff --git a/04-building-container-images/sample-app/api-node/src/index.js b/05-example-web-application/api-node/src/index.js similarity index 86% rename from 04-building-container-images/sample-app/api-node/src/index.js rename to 05-example-web-application/api-node/src/index.js index d88829f..de7610d 100644 --- a/04-building-container-images/sample-app/api-node/src/index.js +++ b/05-example-web-application/api-node/src/index.js @@ -1,10 +1,14 @@ const { getDateTime } = require('./db'); const express = require('express'); +const morgan = require('morgan'); const app = express(); const port = 3000; +// setup the logger +app.use(morgan('tiny')); + app.get('/', async (req, res) => { const dateTime = await getDateTime(); const response = dateTime; diff --git a/04-building-container-images/sample-app/client-react/.dockerignore b/05-example-web-application/client-react/.dockerignore similarity index 100% rename from 04-building-container-images/sample-app/client-react/.dockerignore rename to 05-example-web-application/client-react/.dockerignore diff --git a/04-building-container-images/sample-app/client-react/.gitignore b/05-example-web-application/client-react/.gitignore similarity index 100% rename from 04-building-container-images/sample-app/client-react/.gitignore rename to 05-example-web-application/client-react/.gitignore diff --git a/04-building-container-images/sample-app/client-react/README.md b/05-example-web-application/client-react/README.md similarity index 100% rename from 04-building-container-images/sample-app/client-react/README.md rename to 05-example-web-application/client-react/README.md diff --git a/04-building-container-images/sample-app/client-react/index.html b/05-example-web-application/client-react/index.html similarity index 100% rename from 04-building-container-images/sample-app/client-react/index.html rename to 05-example-web-application/client-react/index.html diff --git a/04-building-container-images/sample-app/client-react/nginx.conf b/05-example-web-application/client-react/nginx.conf similarity index 100% rename from 04-building-container-images/sample-app/client-react/nginx.conf rename to 05-example-web-application/client-react/nginx.conf diff --git a/04-building-container-images/sample-app/client-react/package-lock.json b/05-example-web-application/client-react/package-lock.json similarity index 100% rename from 04-building-container-images/sample-app/client-react/package-lock.json rename to 05-example-web-application/client-react/package-lock.json diff --git a/04-building-container-images/sample-app/client-react/package.json b/05-example-web-application/client-react/package.json similarity index 100% rename from 04-building-container-images/sample-app/client-react/package.json rename to 05-example-web-application/client-react/package.json diff --git a/04-building-container-images/sample-app/client-react/public/favicon.ico b/05-example-web-application/client-react/public/favicon.ico similarity index 100% rename from 04-building-container-images/sample-app/client-react/public/favicon.ico rename to 05-example-web-application/client-react/public/favicon.ico diff --git a/04-building-container-images/sample-app/client-react/src/App.css b/05-example-web-application/client-react/src/App.css similarity index 100% rename from 04-building-container-images/sample-app/client-react/src/App.css rename to 05-example-web-application/client-react/src/App.css diff --git a/04-building-container-images/sample-app/client-react/src/App.jsx b/05-example-web-application/client-react/src/App.jsx similarity index 100% rename from 04-building-container-images/sample-app/client-react/src/App.jsx rename to 05-example-web-application/client-react/src/App.jsx diff --git a/04-building-container-images/sample-app/client-react/src/index.css b/05-example-web-application/client-react/src/index.css similarity index 100% rename from 04-building-container-images/sample-app/client-react/src/index.css rename to 05-example-web-application/client-react/src/index.css diff --git a/04-building-container-images/sample-app/client-react/src/main.jsx b/05-example-web-application/client-react/src/main.jsx similarity index 100% rename from 04-building-container-images/sample-app/client-react/src/main.jsx rename to 05-example-web-application/client-react/src/main.jsx diff --git a/05-example-web-application/client-react/vite.config.js b/05-example-web-application/client-react/vite.config.js new file mode 100644 index 0000000..4434988 --- /dev/null +++ b/05-example-web-application/client-react/vite.config.js @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react-swc'; +import dns from 'dns'; + +dns.setDefaultResultOrder('verbatim'); + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], + server: { + proxy: { + '/api/golang': { + target: 'http://localhost:8080', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api\/golang/, ''), + secure: false, + }, + '/api/node': { + target: 'http://localhost:3000', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api\/node/, ''), + secure: false, + }, + }, + }, +}); diff --git a/04-building-container-images/sample-app/Makefile b/06-building-container-images/Makefile similarity index 79% rename from 04-building-container-images/sample-app/Makefile rename to 06-building-container-images/Makefile index cb56a5b..360ec0b 100644 --- a/04-building-container-images/sample-app/Makefile +++ b/06-building-container-images/Makefile @@ -10,10 +10,6 @@ compose-up: compose-up-build: docker compose up --build -.PHONY: compose-up-db -compose-up-db: - docker compose up -d db - .PHONY: compose-down compose-down: docker compose down \ No newline at end of file diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.0 b/06-building-container-images/api-golang/Dockerfile.0 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.0 rename to 06-building-container-images/api-golang/Dockerfile.0 diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.1 b/06-building-container-images/api-golang/Dockerfile.1 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.1 rename to 06-building-container-images/api-golang/Dockerfile.1 diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.2 b/06-building-container-images/api-golang/Dockerfile.2 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.2 rename to 06-building-container-images/api-golang/Dockerfile.2 diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.3 b/06-building-container-images/api-golang/Dockerfile.3 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.3 rename to 06-building-container-images/api-golang/Dockerfile.3 diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.4 b/06-building-container-images/api-golang/Dockerfile.4 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.4 rename to 06-building-container-images/api-golang/Dockerfile.4 diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.5 b/06-building-container-images/api-golang/Dockerfile.5 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.5 rename to 06-building-container-images/api-golang/Dockerfile.5 diff --git a/04-building-container-images/sample-app/api-golang/Dockerfile.6 b/06-building-container-images/api-golang/Dockerfile.6 similarity index 100% rename from 04-building-container-images/sample-app/api-golang/Dockerfile.6 rename to 06-building-container-images/api-golang/Dockerfile.6 diff --git a/06-building-container-images/api-golang/Makefile b/06-building-container-images/api-golang/Makefile new file mode 100644 index 0000000..1b53676 --- /dev/null +++ b/06-building-container-images/api-golang/Makefile @@ -0,0 +1,12 @@ +API_GOLANG_PATH:=../../05-example-web-application/api-golang/ + +N?=0 +.PHONY: build-N +build-N: + docker build --file ./Dockerfile.$(N) -t api-golang:$(N) ${API_GOLANG_PATH} + +.PHONY: build-all +build-all: + for number in 0 1 2 3 4 5 6 ; do \ + N=$$number $(MAKE) build-N; \ + done \ No newline at end of file diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.0 b/06-building-container-images/api-node/Dockerfile.0 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.0 rename to 06-building-container-images/api-node/Dockerfile.0 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.1 b/06-building-container-images/api-node/Dockerfile.1 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.1 rename to 06-building-container-images/api-node/Dockerfile.1 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.2 b/06-building-container-images/api-node/Dockerfile.2 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.2 rename to 06-building-container-images/api-node/Dockerfile.2 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.3 b/06-building-container-images/api-node/Dockerfile.3 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.3 rename to 06-building-container-images/api-node/Dockerfile.3 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.4 b/06-building-container-images/api-node/Dockerfile.4 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.4 rename to 06-building-container-images/api-node/Dockerfile.4 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.5 b/06-building-container-images/api-node/Dockerfile.5 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.5 rename to 06-building-container-images/api-node/Dockerfile.5 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.6 b/06-building-container-images/api-node/Dockerfile.6 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.6 rename to 06-building-container-images/api-node/Dockerfile.6 diff --git a/04-building-container-images/sample-app/api-node/Dockerfile.7 b/06-building-container-images/api-node/Dockerfile.7 similarity index 100% rename from 04-building-container-images/sample-app/api-node/Dockerfile.7 rename to 06-building-container-images/api-node/Dockerfile.7 diff --git a/06-building-container-images/api-node/Makefile b/06-building-container-images/api-node/Makefile new file mode 100644 index 0000000..07f2e74 --- /dev/null +++ b/06-building-container-images/api-node/Makefile @@ -0,0 +1,12 @@ +API_NODE_PATH:=../../05-example-web-application/api-node/ + +N?=0 +.PHONY: build-N +build-N: + docker build --file ./Dockerfile.$(N) -t api-node:$(N) ${API_NODE_PATH} + +.PHONY: build-all +build-all: + for number in 0 1 2 3 4 5 6 7 ; do \ + N=$$number $(MAKE) build-N; \ + done \ No newline at end of file diff --git a/04-building-container-images/sample-app/client-react/Dockerfile b/06-building-container-images/client-react/Dockerfile similarity index 100% rename from 04-building-container-images/sample-app/client-react/Dockerfile rename to 06-building-container-images/client-react/Dockerfile diff --git a/04-building-container-images/sample-app/client-react/Dockerfile.0 b/06-building-container-images/client-react/Dockerfile.0 similarity index 100% rename from 04-building-container-images/sample-app/client-react/Dockerfile.0 rename to 06-building-container-images/client-react/Dockerfile.0 diff --git a/04-building-container-images/sample-app/client-react/Dockerfile.1 b/06-building-container-images/client-react/Dockerfile.1 similarity index 100% rename from 04-building-container-images/sample-app/client-react/Dockerfile.1 rename to 06-building-container-images/client-react/Dockerfile.1 diff --git a/04-building-container-images/sample-app/client-react/Dockerfile.2 b/06-building-container-images/client-react/Dockerfile.2 similarity index 100% rename from 04-building-container-images/sample-app/client-react/Dockerfile.2 rename to 06-building-container-images/client-react/Dockerfile.2 diff --git a/04-building-container-images/sample-app/client-react/Dockerfile.3 b/06-building-container-images/client-react/Dockerfile.3 similarity index 85% rename from 04-building-container-images/sample-app/client-react/Dockerfile.3 rename to 06-building-container-images/client-react/Dockerfile.3 index 9385af0..6849a60 100644 --- a/04-building-container-images/sample-app/client-react/Dockerfile.3 +++ b/06-building-container-images/client-react/Dockerfile.3 @@ -22,3 +22,7 @@ FROM nginx:1.23-alpine COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build usr/src/app/dist/ /usr/share/nginx/html + +EXPOSE 80 + +# No CMD specified... will uses CMD/ENTRYPOINT from base image (nginx:1.23-alpine) \ No newline at end of file diff --git a/06-building-container-images/client-react/Makefile b/06-building-container-images/client-react/Makefile new file mode 100644 index 0000000..923a2be --- /dev/null +++ b/06-building-container-images/client-react/Makefile @@ -0,0 +1,12 @@ +API_NODE_PATH:=../../05-example-web-application/api-node/ + +N?=0 +.PHONY: build-N +build-N: + docker build --file ./Dockerfile.$(N) -t api-node:$(N) ${API_NODE_PATH} + +.PHONY: build-all +build-all: + for number in 0 1 2 3 ; do \ + N=$$number $(MAKE) build-N; \ + done \ No newline at end of file diff --git a/04-building-container-images/sample-app/client-react/vite.config.js b/06-building-container-images/client-react/vite.config.js similarity index 100% rename from 04-building-container-images/sample-app/client-react/vite.config.js rename to 06-building-container-images/client-react/vite.config.js diff --git a/04-building-container-images/sample-app/docker-compose.yml b/06-building-container-images/docker-compose.yml similarity index 52% rename from 04-building-container-images/sample-app/docker-compose.yml rename to 06-building-container-images/docker-compose.yml index b6de7a4..31db2f2 100644 --- a/04-building-container-images/sample-app/docker-compose.yml +++ b/06-building-container-images/docker-compose.yml @@ -1,21 +1,23 @@ services: client-react: build: - context: ./client-react - dockerfile: Dockerfile + context: ../05-example-web-application/client-react/ + dockerfile: ../../06-building-container-images/client-react/Dockerfile ports: - 5173:5173 + volumes: + - ${PWD}/client-react/vite.config.js:/usr/src/app/vite.config.js client-react-nginx: build: - context: ./client-react - dockerfile: Dockerfile.3 + context: ../05-example-web-application/client-react/ + dockerfile: ../../06-building-container-images/client-react/Dockerfile.3 init: true ports: - 5174:80 api-node: build: - context: ./api-node - dockerfile: Dockerfile.7 + context: ../05-example-web-application/api-node/ + dockerfile: ../../06-building-container-images/api-node/Dockerfile.7 init: true depends_on: - db @@ -29,8 +31,8 @@ services: - 3000:3000 api-golang: build: - context: ./api-golang - dockerfile: Dockerfile.6 + context: ../05-example-web-application/api-golang/ + dockerfile: ../../06-building-container-images/api-golang/Dockerfile.6 init: true depends_on: - db diff --git a/04-building-container-images/sample-dockerfiles/Dockerfile b/06-building-container-images/sample-dockerfiles/Dockerfile similarity index 100% rename from 04-building-container-images/sample-dockerfiles/Dockerfile rename to 06-building-container-images/sample-dockerfiles/Dockerfile