Skip to content

Instantly share code, notes, and snippets.

@JeffryGonzalez
Created October 14, 2021 12:13
Show Gist options
  • Save JeffryGonzalez/12907e17cae59e723e9243816e7fc3b0 to your computer and use it in GitHub Desktop.
Save JeffryGonzalez/12907e17cae59e723e9243816e7fc3b0 to your computer and use it in GitHub Desktop.
Example Dockerfile for creating a node image with Chrome
# Closest node to our current version
FROM node:14.18
# apt is a linux package manager. we update our deps and
RUN apt-get update && apt-get install -y \
# install apt-transport-https (allows us to pull down stuff from https)
apt-transport-https \
# ca-certificates (for the certs for https)
ca-certificates \
# curl is a command line tool for doing web requests
curl \
# the google apt repo has a signing key, this will allow up to verify it.
gnupg \
# After that, get the key and add it to our "trusted keys"
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
# Now that we have the key get the apt repo and add it to our sources (where we can pull stuff from)
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
# Update our database of stuff we can install, including the new stuff from dl.google.com/linux/chrome/deb/
&& apt-get update && apt-get install -y \
# now install google-chrome-stable
google-chrome-stable \
# all those tools and lists we installed? Remove them from the image so it is smaller.
&& apt-get purge --auto-remove -y curl gnupg \
&& rm -rf /var/lib/apt/lists/*
# this is just an example - in most cases you'd want to create a non-root user to run chrome in the container. (the --no-sandbox gets us around that.)
# example command in -it: google-chrome --headless --no-sandbox --disable-gpu --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222
@JeffryGonzalez
Copy link
Author

I created and pushed this to Docker hub.

docker run -it jeffrygonzalez/node-chrome /bin/bash

To try it out.

@mikejancar
Copy link

This is excellent, Jeff. Thank you! Now I'm going to try and see if I can get it to work "within the walls".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment