Coder Social home page Coder Social logo

as-a-service / screenshot Goto Github PK

View Code? Open in Web Editor NEW
103.0 2.0 25.0 49 KB

Screenshot as a service: take screenshot of the given URL

Home Page: https://screenshot.as-a-service.dev/

License: Apache License 2.0

Dockerfile 31.66% JavaScript 68.34%
nodejs headless-chrome docker container microservice cloud-run-button

screenshot's Introduction

Takes a screenshot of the given page

A simple web service that takes screenshot of the given URL.

Run with docker run -p 8080:8080 gcr.io/as-a-service-dev/screenshot

Run on Google Cloud

API

URL parameters:

  • url: The URL of the website to screenshot
  • (width): The viewport width (in pixels), defaults to 1280
  • (height): The viewport height (in pixels), defaults to 800

Example: /?url=https://steren.fr

Running the server locally

  • Build with docker build . -t screenshot
  • Start with docker run -p 8080:8080 screenshot
  • Open in your browser at http://localhost:8080/?url=https://steren.fr

CloudBuild

screenshot's People

Contributors

dependabot[bot] avatar steren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

screenshot's Issues

Crash without `--no-sandbox` on docker

docker run -p 8080:8080 gcr.io/as-a-service-dev/screenshot

> [email protected] start /usr/src/app
> node server.js

App listening on port 8080
(node:19) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[0129/163041.181072:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x55f12282d399 base::debug::CollectStackTrace()
#1 0x55f12278e2a3 base::debug::StackTrace::StackTrace()
#2 0x55f12279fc95 logging::LogMessage::~LogMessage()
#3 0x55f12407c40e service_manager::ZygoteHostImpl::Init()
#4 0x55f122358060 content::ContentMainRunnerImpl::Initialize()
#5 0x55f1223b95e7 service_manager::Main()
#6 0x55f122356631 content::ContentMain()
#7 0x55f1223b880d headless::(anonymous namespace)::RunContentMain()
#8 0x55f1223b850c headless::HeadlessShellMain()
#9 0x55f11fdac5a7 ChromeMain
#10 0x7f00e10bb2e1 __libc_start_main
#11 0x55f11fdac3ea _start

Received signal 6
#0 0x55f12282d399 base::debug::CollectStackTrace()
#1 0x55f12278e2a3 base::debug::StackTrace::StackTrace()
#2 0x55f12282cf35 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f00e76650e0 (/lib/x86_64-linux-gnu/libpthread-2.24.so+0x110df)
#4 0x7f00e10cdfff gsignal
#5 0x7f00e10cf42a abort
#6 0x55f12282be95 base::debug::BreakDebugger()
#7 0x55f1227a0132 logging::LogMessage::~LogMessage()
#8 0x55f12407c40e service_manager::ZygoteHostImpl::Init()
#9 0x55f122358060 content::ContentMainRunnerImpl::Initialize()
#10 0x55f1223b95e7 service_manager::Main()
#11 0x55f122356631 content::ContentMain()
#12 0x55f1223b880d headless::(anonymous namespace)::RunContentMain()
#13 0x55f1223b850c headless::HeadlessShellMain()
#14 0x55f11fdac5a7 ChromeMain
#15 0x7f00e10bb2e1 __libc_start_main
#16 0x55f11fdac3ea _start
  r8: 0000000000000000  r9: 00007ffd118fe250 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffd118ff508 r13: 00007ffd118fe4e0 r14: 00007ffd118ff510 r15: aaaaaaaaaaaaaaaa
  di: 0000000000000002  si: 00007ffd118fe250  bp: 00007ffd118fe490  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f00e10cdfff  sp: 00007ffd118fe2c8
  ip: 00007f00e10cdfff efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/usr/src/app/node_modules/puppeteer/lib/launcher/BrowserRunner.js:159:20)
    at Interface.helper_1.helper.addEventListener (/usr/src/app/node_modules/puppeteer/lib/launcher/BrowserRunner.js:149:65)
    at Interface.emit (events.js:203:15)
    at Interface.close (readline.js:397:8)
    at Socket.onend (readline.js:173:10)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:19) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:19) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[0129/163046.759697:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x563765cd1399 base::debug::CollectStackTrace()
#1 0x563765c322a3 base::debug::StackTrace::StackTrace()
#2 0x563765c43c95 logging::LogMessage::~LogMessage()
#3 0x56376752040e service_manager::ZygoteHostImpl::Init()
#4 0x5637657fc060 content::ContentMainRunnerImpl::Initialize()
#5 0x56376585d5e7 service_manager::Main()
#6 0x5637657fa631 content::ContentMain()
#7 0x56376585c80d headless::(anonymous namespace)::RunContentMain()
#8 0x56376585c50c headless::HeadlessShellMain()
#9 0x5637632505a7 ChromeMain
#10 0x7f4f80bd32e1 __libc_start_main
#11 0x5637632503ea _start

Received signal 6
#0 0x563765cd1399 base::debug::CollectStackTrace()
#1 0x563765c322a3 base::debug::StackTrace::StackTrace()
#2 0x563765cd0f35 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f4f8717d0e0 (/lib/x86_64-linux-gnu/libpthread-2.24.so+0x110df)
#4 0x7f4f80be5fff gsignal
#5 0x7f4f80be742a abort
#6 0x563765ccfe95 base::debug::BreakDebugger()
#7 0x563765c44132 logging::LogMessage::~LogMessage()
#8 0x56376752040e service_manager::ZygoteHostImpl::Init()
#9 0x5637657fc060 content::ContentMainRunnerImpl::Initialize()
#10 0x56376585d5e7 service_manager::Main()
#11 0x5637657fa631 content::ContentMain()
#12 0x56376585c80d headless::(anonymous namespace)::RunContentMain()
#13 0x56376585c50c headless::HeadlessShellMain()
#14 0x5637632505a7 ChromeMain
#15 0x7f4f80bd32e1 __libc_start_main
#16 0x5637632503ea _start
  r8: 0000000000000000  r9: 00007ffdf38cf8a0 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffdf38d0b58 r13: 00007ffdf38cfb30 r14: 00007ffdf38d0b60 r15: aaaaaaaaaaaaaaaa
  di: 0000000000000002  si: 00007ffdf38cf8a0  bp: 00007ffdf38cfae0  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f4f80be5fff  sp: 00007ffdf38cf918
  ip: 00007f4f80be5fff efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/usr/src/app/node_modules/puppeteer/lib/launcher/BrowserRunner.js:159:20)
    at Interface.helper_1.helper.addEventListener (/usr/src/app/node_modules/puppeteer/lib/launcher/BrowserRunner.js:149:65)
    at Interface.emit (events.js:203:15)
    at Interface.close (readline.js:397:8)
    at Socket.onend (readline.js:173:10)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:19) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Using the latest version from GCR.

Remove --no-sandbox

When I do so, I get:

[0114/062147.318868:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

We probably should use a docker user

Possible to call remotely?

Is there a way to call this remotely from another application and it returns the image content in some formats like base64?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.