diff --git a/.gitignore b/.gitignore index 77d4b74..e07dfcc 100644 --- a/.gitignore +++ b/.gitignore @@ -134,3 +134,4 @@ build/ # Secrets tokens.json +docker-compose.yml diff --git a/docker-compose.yml.example b/docker-compose.yml.example new file mode 100644 index 0000000..c6d8038 --- /dev/null +++ b/docker-compose.yml.example @@ -0,0 +1,14 @@ +version: "3.8" + +services: + app: + image: jvik/elaway-gateway-api:latest + environment: + - ELAWAY_USER= + - ELAWAY_PASSWORD= + - ELAWAY_CLIENT_ID= + - ELAWAY_CLIENT_SECRET= + - CLIENT_ID= + - PORT=3000 + ports: + - "3000:3000" diff --git a/dockerfile b/dockerfile index c3cc398..fdd828a 100644 --- a/dockerfile +++ b/dockerfile @@ -1,5 +1,16 @@ -# Use the official Node.js image as a base image -FROM node:20.11.0 +FROM node:slim + +# We don't need the standalone Chromium +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true + +# Install Google Chrome Stable and fonts +# Note: this installs the necessary libs to make the browser work with Puppeteer. +RUN apt-get update && apt-get install gnupg wget -y && \ + wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \ + sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \ + apt-get update && \ + apt-get install google-chrome-stable -y --no-install-recommends && \ + rm -rf /var/lib/apt/lists/* # Set the working directory inside the container WORKDIR /app diff --git a/src/auth.ts b/src/auth.ts index 2ba6b99..1b64f06 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -151,7 +151,7 @@ async function startOauth(): Promise { let accessIdResponse: null | IdTokenResponse = null; const authUrl = `${elawayAuthorizationUrl}?response_type=code&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(oauthScope)}&state=${encodeURIComponent(state)}`; - const browser = await puppeteer.launch({ headless: true }); + const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] }); const page = await browser.newPage(); try {