vechain / thor-sync.electron

A browser that empowers DApps on VeChain
GNU Lesser General Public License v3.0
55 stars 28 forks source link

Suggestion about how to use the Demo within a container #502

Closed rianby64 closed 2 years ago

rianby64 commented 2 years ago

I was trying to launch the demo provided in the documentation How to Develop a DApp and found myself all day trying to figure out how to launch the command npm run dev.

Finally I got this Dockerfile. Maybe somebody else will find this useful.

FROM docker.io/library/centos

RUN echo -e "\
[google-chrome]\n\
name=google-chrome\n\
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://dl.google.com/linux/linux_signing_key.pub" > /etc/yum.repos.d/google-chrome.repo

RUN yum -y install epel-release
RUN yum -y update
RUN yum -y install python2 make gcc-c++ nodejs libudev-devel dbus-x11.x86_64 \
    wget.x86_64 \
    google-chrome-stable.x86_64 \
    git.x86_64 \
    unzip.x86_64 \
    mesa-libGL.x86_64 \
    mesa-dri-drivers.x86_64 \
    xorg-x11-drv-intel.x86_64 \
    libXrender.x86_64 \
    libXtst.x86_64 \
    xorg-x11-fonts-100dpi.noarch \
    xorg-x11-fonts-75dpi.noarch \
    xorg-x11-fonts-ISO8859-1-100dpi.noarch \
    xorg-x11-fonts-ISO8859-1-75dpi.noarch \
    xorg-x11-fonts-ISO8859-14-100dpi.noarch \
    xorg-x11-fonts-ISO8859-14-75dpi.noarch \
    xorg-x11-fonts-ISO8859-15-100dpi.noarch \
    xorg-x11-fonts-ISO8859-15-75dpi.noarch \
    xorg-x11-fonts-ISO8859-2-100dpi.noarch \
    xorg-x11-fonts-ISO8859-2-75dpi.noarch \
    xorg-x11-fonts-ISO8859-9-100dpi.noarch \
    xorg-x11-fonts-ISO8859-9-75dpi.noarch \
    xorg-x11-fonts-Type1.noarch \
    xorg-x11-fonts-cyrillic.noarch \
    xorg-x11-fonts-ethiopic.noarch \
    xorg-x11-fonts-misc.noarch \
    libcanberra-gtk3.x86_64
RUN yum -y install libXScrnSaver

RUN useradd rianby64
USER rianby64
RUN mkdir -p /home/rianby64/Test/vechain
WORKDIR /home/rianby64/Test/vechain
RUN git clone https://github.com/vechain/thor-sync.electron.git thor
WORKDIR /home/rianby64/Test/vechain/thor
RUN npm install

CMD [ "bash" ]
podman build -f Dockerfile -t thor .

podman run -it --rm \
    --user $(id -u):$(id -g) --userns=keep-id \
    --device /dev/dri \
    --ipc=host \
    -e DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
    thor bash

And inside the container, launch npm run dev