From a46528d2e6f269be97a175e89ef24d2831a1b404 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:12:14 -0500 Subject: [PATCH 1/8] Try to run on Heroku --- app.json | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app.json diff --git a/app.json b/app.json new file mode 100644 index 0000000..c23d4e7 --- /dev/null +++ b/app.json @@ -0,0 +1,23 @@ +{ + "name": "SVG to Image Proxy", + "description": "A web service to create PNGs from SVGs", + "keywords": ["svg", "png", "image", "proxy"], + "website": "https://shields.io/", + "repository": "https://github.com/badges/svg-to-iamge-proxy", + "logo": "httpx://shields.io/favicon.png", + "env": { + "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD": { + "value": "false" + }, + "BASE_URL": { + "description": "The server that is hosting the SVGs", + "required": true + } + }, + "formation": { + "web": { + "quantity": 1, + "size": "free" + } + } +} From 735896039710eadc48ac7659e4719d6e4a42260d Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:14:33 -0500 Subject: [PATCH 2/8] Add buildpacks --- app.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app.json b/app.json index c23d4e7..652500e 100644 --- a/app.json +++ b/app.json @@ -5,6 +5,11 @@ "website": "https://shields.io/", "repository": "https://github.com/badges/svg-to-iamge-proxy", "logo": "httpx://shields.io/favicon.png", + "buildpacks": [ + { + "url": "jontewks/puppeteer" + } + ], "env": { "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD": { "value": "false" From 6832131994d13567456ea1093437069d5fa4dc89 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:31:00 -0500 Subject: [PATCH 3/8] Fixes --- app.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index 652500e..d20e7b5 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,7 @@ "keywords": ["svg", "png", "image", "proxy"], "website": "https://shields.io/", "repository": "https://github.com/badges/svg-to-iamge-proxy", - "logo": "httpx://shields.io/favicon.png", + "logo": "https://raw.githubusercontent.com/badges/shields/master/frontend/images/logo.svg?sanitize=true", "buildpacks": [ { "url": "jontewks/puppeteer" diff --git a/package.json b/package.json index 2b9459e..9296547 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "prettier:check": "prettier --check \"**/*.@(js|md|yml|json)\"", "mocha": "BASE_URL=https://img.example.test mocha test.js", "test": "run-p lint prettier:check mocha", - "start": "micro" + "start": "micro --listen tcp://0.0.0.0:${PORT-3000}" }, "repository": "badges/svg-to-image-proxy", "author": "Paul Melnikow", From 6c0bc71db963de33e1f3127b9a0508c57c3bfabc Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:38:50 -0500 Subject: [PATCH 4/8] Keep node buildpack --- app.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.json b/app.json index d20e7b5..15b6d2c 100644 --- a/app.json +++ b/app.json @@ -8,6 +8,9 @@ "buildpacks": [ { "url": "jontewks/puppeteer" + }, + { + "url": "heroku/nodejs" } ], "env": { From 0cce990d5a7cf97eea6b108fb25d8fe40e13aa91 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:43:24 -0500 Subject: [PATCH 5/8] Updates --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6d92116..0fcc24b 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict' const { URL } = require('url') -const chrome = require('chrome-aws-lambda') +// const chrome = require('chrome-aws-lambda') const { createConverter } = require('convert-svg-to-png') const got = require('got') const isSvg = require('is-svg') @@ -28,9 +28,10 @@ let cleanup async function setup() { const converter = createConverter({ puppeteer: { - args: chrome.args, - executablePath: await chrome.executablePath, - headless: chrome.headless, + args: ['--no-sandbox'], + // args: chrome.args, + // executablePath: await chrome.executablePath, + // headless: chrome.headless, }, }) cleanup = async () => converter.destroy() From 166784f2e77e75d0bbcc826df6f0124852bf6838 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:47:31 -0500 Subject: [PATCH 6/8] Try this? --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 9296547..6978e15 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ }, "homepage": "https://github.com/badges/svg-to-image-proxy#readme", "dependencies": { - "chrome-aws-lambda": "^1.18.0", "convert-svg-to-png": "^0.5.0", "got": "^9.6.0", "is-svg": "^4.2.0", From f638e77f840ff7b6dfae94be0f265f74f0c29516 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 13:53:02 -0500 Subject: [PATCH 7/8] Remove some --- package-lock.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index a240c99..fe731b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -257,11 +257,6 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, - "chrome-aws-lambda": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/chrome-aws-lambda/-/chrome-aws-lambda-1.18.1.tgz", - "integrity": "sha512-bq17kJcklPE35qq954bOlHg8RcZvDnfRIjGNerkRXLL0FEqMXqIKYW6SY9/05cUZoYyv0BwQ3JkwtQEjawYWDg==" - }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", From 1ebf3c6dadaa08043d81a4a90d0a1af5813dba54 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 23 Jul 2019 14:22:09 -0500 Subject: [PATCH 8/8] With chrome-aws-lambda --- index.js | 10 +++++----- package-lock.json | 5 +++++ package.json | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 0fcc24b..adb1b96 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict' const { URL } = require('url') -// const chrome = require('chrome-aws-lambda') +const chrome = require('chrome-aws-lambda') const { createConverter } = require('convert-svg-to-png') const got = require('got') const isSvg = require('is-svg') @@ -28,10 +28,10 @@ let cleanup async function setup() { const converter = createConverter({ puppeteer: { - args: ['--no-sandbox'], - // args: chrome.args, - // executablePath: await chrome.executablePath, - // headless: chrome.headless, + // args: ['--no-sandbox'], + args: chrome.args, + executablePath: await chrome.executablePath, + headless: chrome.headless, }, }) cleanup = async () => converter.destroy() diff --git a/package-lock.json b/package-lock.json index fe731b0..760e134 100644 --- a/package-lock.json +++ b/package-lock.json @@ -257,6 +257,11 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, + "chrome-aws-lambda": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/chrome-aws-lambda/-/chrome-aws-lambda-1.19.0.tgz", + "integrity": "sha512-GTrnlZLjFni+qlGTWFcjiJPhmaV+cR/QVDTcDdNRxZm8NQKfopaVv03PLSLP6StzpC0BHquUg6tqz5QH0w1lIw==" + }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", diff --git a/package.json b/package.json index 6978e15..9296547 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "homepage": "https://github.com/badges/svg-to-image-proxy#readme", "dependencies": { + "chrome-aws-lambda": "^1.18.0", "convert-svg-to-png": "^0.5.0", "got": "^9.6.0", "is-svg": "^4.2.0",