From 4fd50886d6f607a5331cd09f61a2e85d2e438656 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Wed, 3 Jun 2020 15:35:40 +0200 Subject: [PATCH 01/10] Add ci --- .github/workflows/walhall-ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/walhall-ci.yml diff --git a/.github/workflows/walhall-ci.yml b/.github/workflows/walhall-ci.yml new file mode 100644 index 0000000..184757a --- /dev/null +++ b/.github/workflows/walhall-ci.yml @@ -0,0 +1,19 @@ +name: Walhall CI + +on: + push: + branches: + - deploy + +jobs: + push-to-humanitec-dev: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Build and Push to Humanitec Dev + uses: humanitec/build-push-to-humanitec@v1 + with: + humanitec-token: ${{ secrets.HUMANITEC_TOKEN_DEV }} + organization: damien85 + humanitec-registry: dev-registry.humanitec.io + humanitec-api: dev-api.humanitec.io \ No newline at end of file From ee23e985a1fd51e7242d9b3b84839e62331bf137 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Wed, 3 Jun 2020 16:15:24 +0200 Subject: [PATCH 02/10] Update port --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e725d60..d1caab3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,7 +33,7 @@ services: - "5432" ports: - - "5432:5432" + - "5432" environment: POSTGRES_PASSWORD: pgsqlDev01 From a94e9788da8d990f3be2a790e829592308136164 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Mon, 8 Jun 2020 17:47:07 +0200 Subject: [PATCH 03/10] Update connection string --- db/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/db/index.js b/db/index.js index ccee7de..7a2a02e 100644 --- a/db/index.js +++ b/db/index.js @@ -1,11 +1,7 @@ const { Pool } = require("pg"); const pool = new Pool({ - user: process.env.DATABASE_USER, - host: process.env.DATABASE_HOST, - database: process.env.DATABASE_NAME, - password: process.env.DATABASE_PASSWORD, - port: process.env.DATABASE_PORT, + connectionString: `postgresql://${process.env.CONNECTION_STRING}` }); module.exports = { From db214b3eb2a77ea6fc71f8fc32020b841b07e663 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 11:00:28 +0200 Subject: [PATCH 04/10] Update connection string --- bin/init_db.js | 1 + db/index.js | 7 +++++++ docker-compose.yml | 2 ++ package.json | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/init_db.js b/bin/init_db.js index d72f979..8644d12 100644 --- a/bin/init_db.js +++ b/bin/init_db.js @@ -2,6 +2,7 @@ const db = require("../db"); console.log("[init_db.js] Initializing database"); +console.log(`[init_db.js] CONNECTION_STRING="${process.env.CONNECTION_STRING || ""}"`); console.log(`[init_db.js] DATABASE_USER="${process.env.DATABASE_USER || ""}"`); console.log(`[init_db.js] DATABASE_HOST="${process.env.DATABASE_HOST || ""}"`); console.log(`[init_db.js] DATABASE_NAME="${process.env.DATABASE_NAME || ""}"`); diff --git a/db/index.js b/db/index.js index 7a2a02e..a92438a 100644 --- a/db/index.js +++ b/db/index.js @@ -2,8 +2,15 @@ const { Pool } = require("pg"); const pool = new Pool({ connectionString: `postgresql://${process.env.CONNECTION_STRING}` + // user: process.env.DATABASE_USER, + // host: process.env.DATABASE_HOST, + // database: process.env.DATABASE_NAME, + // password: process.env.DATABASE_PASSWORD, + // port: process.env.DATABASE_PORT, }); +// console.log('pool: ', pool.); + module.exports = { query: (text, params) => pool .query(text, params) diff --git a/docker-compose.yml b/docker-compose.yml index d1caab3..fef4d8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,10 +14,12 @@ services: - productdb environment: + CONNECTION_STRING: postgresql://product_robot:pr0dr0b0t@productdb:5432/product DATABASE_HOST: productdb DATABASE_NAME: product DATABASE_USER: product_robot DATABASE_PASSWORD: "pr0dr0b0t" + DATABASE_PORT: 5432 productdb: image: postgres:11 diff --git a/package.json b/package.json index f49d0ec..f61f689 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,6 @@ "express-promise-router": "^3.0.3", "morgan": "^1.9.1", "path": "^0.12.7", - "pg": "^7.12.1" + "pg": "^8.2.1" } } From 6a42e7e4b0830110d94009a51cb30365480c44be Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 11:00:41 +0200 Subject: [PATCH 05/10] Update connection string --- db/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/index.js b/db/index.js index a92438a..ea96ace 100644 --- a/db/index.js +++ b/db/index.js @@ -1,7 +1,7 @@ const { Pool } = require("pg"); const pool = new Pool({ - connectionString: `postgresql://${process.env.CONNECTION_STRING}` + connectionString: `${process.env.CONNECTION_STRING}` // user: process.env.DATABASE_USER, // host: process.env.DATABASE_HOST, // database: process.env.DATABASE_NAME, From 6d41b2e822c43eecca83708ada45093d011e5ec4 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 11:14:39 +0200 Subject: [PATCH 06/10] Log connection string --- db/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/index.js b/db/index.js index ea96ace..a86b672 100644 --- a/db/index.js +++ b/db/index.js @@ -9,6 +9,8 @@ const pool = new Pool({ // port: process.env.DATABASE_PORT, }); +console.log('connectionstring: ', process.env.CONNECTION_STRING) + // console.log('pool: ', pool.); module.exports = { From a163d6ba96d2066d50406b3a7464a9333c519bab Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 11:21:18 +0200 Subject: [PATCH 07/10] Remove from docker compose --- db/index.js | 1 - docker-compose.yml | 8 -------- routes/products.js | 1 + 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/db/index.js b/db/index.js index a86b672..3ce39b5 100644 --- a/db/index.js +++ b/db/index.js @@ -9,7 +9,6 @@ const pool = new Pool({ // port: process.env.DATABASE_PORT, }); -console.log('connectionstring: ', process.env.CONNECTION_STRING) // console.log('pool: ', pool.); diff --git a/docker-compose.yml b/docker-compose.yml index fef4d8d..a908b6c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,14 +13,6 @@ services: depends_on: - productdb - environment: - CONNECTION_STRING: postgresql://product_robot:pr0dr0b0t@productdb:5432/product - DATABASE_HOST: productdb - DATABASE_NAME: product - DATABASE_USER: product_robot - DATABASE_PASSWORD: "pr0dr0b0t" - DATABASE_PORT: 5432 - productdb: image: postgres:11 diff --git a/routes/products.js b/routes/products.js index a6014fd..5b0f54b 100644 --- a/routes/products.js +++ b/routes/products.js @@ -16,6 +16,7 @@ function toProduct(row) { } router.get("/", async (req, res) => { + console.log('connectionstring: ', process.env.CONNECTION_STRING) const { rows } = await db.query("SELECT id, title, content, created_at FROM products"); res.setHeader("Access-Control-Allow-Origin", "*"); res.json(rows.map(toProduct)); From 3cf9b801e7e80ed8f674c05ca0fd0565e6ed83b8 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 11:49:04 +0200 Subject: [PATCH 08/10] Remove postgres from docker-compose --- docker-compose.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a908b6c..85e3750 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,25 +9,3 @@ services: ports: - "8080:8080" - - depends_on: - - productdb - - productdb: - image: postgres:11 - - volumes: - # Volume for startup scripts. Note this willonly run if there is nothing in /var/lib/postgresql/data - - ./devdatabase/db-init-scripts:/docker-entrypoint-initdb.d - - # Volume for persistance between runs. Uncomment if you wish to retain data. - # - ./devdatabase/volume:/var/lib/postgresql/data - - expose: - - "5432" - - ports: - - "5432" - - environment: - POSTGRES_PASSWORD: pgsqlDev01 From 4d24a5c1c656d5a0004eefbac44e1bcf0f93d229 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 13:53:30 +0200 Subject: [PATCH 09/10] Remove comments --- db/index.js | 8 -------- docker-compose.yml | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/db/index.js b/db/index.js index 3ce39b5..fe3e95a 100644 --- a/db/index.js +++ b/db/index.js @@ -2,16 +2,8 @@ const { Pool } = require("pg"); const pool = new Pool({ connectionString: `${process.env.CONNECTION_STRING}` - // user: process.env.DATABASE_USER, - // host: process.env.DATABASE_HOST, - // database: process.env.DATABASE_NAME, - // password: process.env.DATABASE_PASSWORD, - // port: process.env.DATABASE_PORT, }); - -// console.log('pool: ', pool.); - module.exports = { query: (text, params) => pool .query(text, params) diff --git a/docker-compose.yml b/docker-compose.yml index 85e3750..aad4071 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,3 +9,28 @@ services: ports: - "8080:8080" + + depends_on: + - productdb + + environment: + CONNECTION_STRING: postgresql://product_robot:pr0dr0b0t@productdb:5432/product + + productdb: + image: postgres:11 + + volumes: + # Volume for startup scripts. Note this willonly run if there is nothing in /var/lib/postgresql/data + - ./devdatabase/db-init-scripts:/docker-entrypoint-initdb.d + + # Volume for persistance between runs. Uncomment if you wish to retain data. + # - ./devdatabase/volume:/var/lib/postgresql/data + + expose: + - "5432" + + ports: + - "5432:5432" + + environment: + POSTGRES_PASSWORD: pgsqlDev01 From 499a19178660145dc498d26d425f43e6ec397f55 Mon Sep 17 00:00:00 2001 From: damien-duignan Date: Tue, 9 Jun 2020 13:55:29 +0200 Subject: [PATCH 10/10] Remove console log --- routes/products.js | 1 - 1 file changed, 1 deletion(-) diff --git a/routes/products.js b/routes/products.js index 5b0f54b..a6014fd 100644 --- a/routes/products.js +++ b/routes/products.js @@ -16,7 +16,6 @@ function toProduct(row) { } router.get("/", async (req, res) => { - console.log('connectionstring: ', process.env.CONNECTION_STRING) const { rows } = await db.query("SELECT id, title, content, created_at FROM products"); res.setHeader("Access-Control-Allow-Origin", "*"); res.json(rows.map(toProduct));