Skip to content

Instantly share code, notes, and snippets.

@hareeshpc
Created June 13, 2021 09:24
Show Gist options
  • Save hareeshpc/a4d5736aa385478e30faf05a190d76cb to your computer and use it in GitHub Desktop.
Save hareeshpc/a4d5736aa385478e30faf05a190d76cb to your computer and use it in GitHub Desktop.
Based on : https://github.com/jessfraz/dockerfiles/blob/master/chrome/stable/Dockerfile
Dockerfile
==========
```
# Base docker image
FROM debian:bullseye-slim
LABEL maintainer "Jessie Frazelle <[email protected]>"
# Install Chrome
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
hicolor-icon-theme \
libcanberra-gtk* \
libgl1-mesa-dri \
libgl1-mesa-glx \
libpangox-1.0-0 \
libpulse0 \
libv4l-0 \
fonts-symbola \
--no-install-recommends \
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update && apt-get install -y \
google-chrome-stable \
--no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*
# Add chrome user
RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome \
&& mkdir -p /home/chrome/Downloads && chown -R chrome:chrome /home/chrome
COPY local.conf /etc/fonts/local.conf
# Run Chrome as non privileged user
USER chrome
# Autorun chrome
ENTRYPOINT [ "google-chrome" ]
CMD [ "--user-data-dir=/data" ]
```
local.conf
=========
```
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
<bool>true</bool>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hintstyle">
<const>hintslight</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
</match>
<match target="font">
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>
<match target="font">
<edit name="embeddedbitmap" mode="assign">
<bool>false</bool>
</edit>
</match>
</fontconfig>
```
run
===
```
xhost +
docker run -it --rm --net host --cpuset-cpus 0 -v tmp-dir:/home/chrome/:rw --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --security-opt seccomp=$HOME/chrome.json --name chrome my-chrome:0.1
#docker run -it \
# --net host \ # may as well YOLO
# --cpuset-cpus 0 \ # control the cpu
# --memory 512mb \ # max memory it can use
# -v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
# -e DISPLAY=unix$DISPLAY \
# -v $HOME/Downloads:/home/chrome/Downloads \
# -v $HOME/.config/google-chrome/:/data \ # if you want to save state
# --security-opt seccomp=$HOME/chrome.json \
# --device /dev/snd \ # so we have sound
# --device /dev/dri \
# -v /dev/shm:/dev/shm \
# --name chrome \
# jess/chrome
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment