aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-06-28 01:40:19 +0530
committerBobby <[email protected]>2022-06-28 01:40:19 +0530
commit0116830ed57b837dbc17edf1a7ed3f06ae1ebf16 (patch)
tree1cdcbe76fab0b8474a98d48242d1fa4387fac009
parentf5ddd646b2b36686519395e5c9d1af52cc11de18 (diff)
downloadthatcomputerscientist-0116830ed57b837dbc17edf1a7ed3f06ae1ebf16.tar.xz
thatcomputerscientist-0116830ed57b837dbc17edf1a7ed3f06ae1ebf16.zip
Configuring Dockerfile to run Headless Chromium
-rw-r--r--Dockerfile12
-rw-r--r--routes/api/screenshot.js4
-rw-r--r--site.config.yml2
3 files changed, 17 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..2467eb6b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM zenika/alpine-chrome:89-with-node-14
+
+COPY package*.json ./
+
+RUN npm install
+
+COPY . .
+
+ENV PUPPETEER_EXECUTABLE_PATH='/usr/bin/chromium-browser'
+
+EXPOSE 8080
+CMD [ "node", "server.js" ]
diff --git a/routes/api/screenshot.js b/routes/api/screenshot.js
index f1ed3297..f55ffc10 100644
--- a/routes/api/screenshot.js
+++ b/routes/api/screenshot.js
@@ -1,13 +1,15 @@
const router = require("express").Router();
const puppeteer = require("puppeteer");
const fs = require("fs");
+const yaml = require("yaml");
+const config = yaml.parse(fs.readFileSync("site.config.yml", "utf8"));
router.get("/", async (req, res) => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.setViewport({ width: 1920, height: 1080 });
// Go to the url
- await page.goto("https://www.thatcomputerscientist.com/", {
+ await page.goto(config.url, {
waitUntil: "networkidle2",
});
// Take a screenshot
diff --git a/site.config.yml b/site.config.yml
index bf23097e..6992e660 100644
--- a/site.config.yml
+++ b/site.config.yml
@@ -1,2 +1,4 @@
# This file contains all the global configuration for the website
domain: 'thatcomputerscientist.com'
+url: 'https://www.thatcomputerscientist.com'
+title: 'That Computer Scientist' \ No newline at end of file