diff --git a/05-example-web-application/api-golang/nohup.out b/05-example-web-application/api-golang/nohup.out deleted file mode 100644 index 466d878..0000000 --- a/05-example-web-application/api-golang/nohup.out +++ /dev/null @@ -1,94 +0,0 @@ -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/05-example-web-application/api-node/Makefile b/05-example-web-application/api-node/Makefile index dfeef82..8473735 100644 --- a/05-example-web-application/api-node/Makefile +++ b/05-example-web-application/api-node/Makefile @@ -1,10 +1,6 @@ .PHONY: run-local run-local: - PGUSER=postgres \ - PGHOST=localhost \ - PGPASSWORD=foobarbaz \ - PGDATABASE=postgres \ - PGPORT=5432 \ + DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \ node ./src/index.js .PHONY: build-naive diff --git a/05-example-web-application/api-node/src/db.js b/05-example-web-application/api-node/src/db.js index 582169f..ff726e5 100644 --- a/05-example-web-application/api-node/src/db.js +++ b/05-example-web-application/api-node/src/db.js @@ -1,6 +1,8 @@ const { Pool } = require('pg'); -const pool = new Pool(); +const pool = new Pool({ + connectionString: process.env.DATABASE_URL, +}); // the pool will emit an error on behalf of any idle clients // it contains if a backend error or network partition happens diff --git a/06-building-container-images/docker-compose.yml b/06-building-container-images/docker-compose.yml index 0332079..fb9c887 100644 --- a/06-building-container-images/docker-compose.yml +++ b/06-building-container-images/docker-compose.yml @@ -22,11 +22,7 @@ services: depends_on: - db environment: - - PGUSER=postgres - - PGHOST=db - - PGPASSWORD=foobarbaz - - PGDATABASE=postgres - - PGPORT=5432 + - DATABASE_URL=postgres://postgres:foobarbaz@db:5432/postgres ports: - 3000:3000 api-golang: