diff --git a/Dockerfile b/Dockerfile index 104c3a8..1183d81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,8 @@ FROM jlesage/baseimage-gui:ubuntu-20.04-v4 AS builder ARG LOCALE="en-US" -ENV TOR_VERSION_X64="x86_64-12.0.4" -ENV TOR_VERSION_ARM64="12.0.3" +ENV TOR_VERSION_X64="12.0.4" +ENV TOR_VERSION_ARM64="12.0.4" # automatic; passed in by Docker buildx ARG TARGETARCH @@ -88,9 +88,7 @@ RUN apt-get update \ file \ libdbus-glib-1-2 \ libgtk-3-0 \ - libx11-xcb1 \ - libxt6 \ - libasound2 \ + vlc xclip vim \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /app /app @@ -99,6 +97,8 @@ COPY --from=builder /opt/noVNC/index.html /opt/noVNC/index.html COPY browser-cfg /browser-cfg COPY startapp.sh /startapp.sh +COPY run/pulse-client.conf /etc/pulse/client.conf EXPOSE 5800 EXPOSE 5900 + diff --git a/.gitlab-ci.yml b/_.gitlab-ci.yml similarity index 100% rename from .gitlab-ci.yml rename to _.gitlab-ci.yml diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..4d4b873 --- /dev/null +++ b/build.bat @@ -0,0 +1 @@ +docker build -t domistyle/tor-browser . diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..1e1725a --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# + +docker build -t domistyle/tor-browser . + diff --git a/run/.gitignore b/run/.gitignore new file mode 100644 index 0000000..42134f6 --- /dev/null +++ b/run/.gitignore @@ -0,0 +1,2 @@ +pulse-client.conf +tor.opts.sh diff --git a/run/audio.sh b/run/audio.sh new file mode 100755 index 0000000..3b0626a --- /dev/null +++ b/run/audio.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Starts Pulse Audio server: +# listening on default port (4713) +# allowing anonymous connections + +DEBUG="-v" +DEBUG="" + +echo "Starting Pulse Audio" +pulseaudio $DEBUG --load="module-native-protocol-tcp auth-anonymous=1" --exit-idle-time=-1 --use-pid-file=1 + diff --git a/run/pulse-client.any-tcp.conf b/run/pulse-client.any-tcp.conf new file mode 100644 index 0000000..3b5a6bd --- /dev/null +++ b/run/pulse-client.any-tcp.conf @@ -0,0 +1,9 @@ +# Works on everything +default-server = tcp:host.docker.internal + +# Prevent a server running in the container +autospawn = no +daemon-binary = /bin/true + +# Prevent the use of shared memory +enable-shm = false diff --git a/run/pulse-client.linux-native.conf b/run/pulse-client.linux-native.conf new file mode 100644 index 0000000..e88d0fc --- /dev/null +++ b/run/pulse-client.linux-native.conf @@ -0,0 +1,9 @@ +# Linux to Linux works, couldn't get Mac to work, won't work on Windows +default-server = unix:/run/user/1000/pulse/native + +# Prevent a server running in the container +autospawn = no +daemon-binary = /bin/true + +# Prevent the use of shared memory +enable-shm = false diff --git a/run/tor b/run/tor new file mode 100755 index 0000000..46cf636 --- /dev/null +++ b/run/tor @@ -0,0 +1,99 @@ +#!/bin/bash +# set -x +# +# $HOME/Development/git/docker-tor-browser +# + +# https://stackoverflow.com/a/4774063/1700121 +RUN="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +DN=/dev/null +PA_PID="$HOME/.config/pulse/`hostname`-runtime/pid" + +. $RUN/tor.opts.default.sh + +if [ -f $RUN/tor.opts.sh ] +then + . $RUN/tor.opts.sh +fi + +docker ps > /dev/null +if [ $? -ne 0 ] +then + + echo "Docker not running" + exit 1 +fi + +if [ ! -z "$SHARED_LOCAL_FOLDER" -a ! -d "$SHARED_LOCAL_FOLDER" ] +then + echo "Can not find $SHARED_LOCAL_FOLDER" + exit 1 +fi + +PLAT=$(uname) +EXTERNAL_PORT_PULSEAUDIO=4713 +PARAMS=() +PARAMS+=("-d") # +PARAMS+=("--shm-size=2g") # +PARAMS+=("--add-host host.docker.internal:$HOST_IP") # +PARAMS+=("-p 127.0.0.1:$EXTERNAL_PORT_VNC:5800") # +PARAMS+=("-p 127.0.0.1:$EXTERNAL_PORT_PULSEAUDIO:4713") # +PARAMS+=("-e DISPLAY_WIDTH=$DISPLAY_WIDTH") # +PARAMS+=("-e DISPLAY_HEIGHT=$DISPLAY_HEIGHT") # +if [ ! -z "$SHARED_LOCAL_FOLDER" ] +then + PARAMS+=("-v $SHARED_LOCAL_FOLDER:/app/host") # +fi +if [ "$PLAT" = "Linux" ] +then + PARAMS+=("-v /run/user/1000/pulse:/run/user/1000/pulse") # + USE_NATIVE_PA="1" +else + USE_NATIVE_PA="0" +fi + + +DOCKER_INSTANCE_ID=$(docker run ${PARAMS[*]} "$DOCKER_IMAGE_TAG") + +IMAGE_ID=${DOCKER_INSTANCE_ID:0:12} + +echo "" +echo "http://localhost:$EXTERNAL_PORT_VNC/" +echo "" +echo "Full Id: $DOCKER_INSTANCE_ID" +echo "" +echo "# docker kill $IMAGE_ID" +echo "IMAGE_ID=$IMAGE_ID" + +echo "docker exec -it $IMAGE_ID /bin/bash" +echo "setclip 'file:///app/host/home.html'" + +docker ps --format "{{.ID}} {{.Image}} {{.Status}}" +echo "" + +if [ "$USE_NATIVE_PA" = "1" ] +then + echo "Using native pulse audio" +else + $RUN/audio.sh & +fi + +echo "" +echo "" +echo "Starting shell...." +echo "" +echo "" +docker exec -it $IMAGE_ID /bin/bash +echo "" +echo "Waiting for docker to end..." +docker wait $IMAGE_ID + +if [ "$USE_NATIVE_PA" != "1" ] +then + PID=`cat $PA_PID` + echo "Killing PA (pid=$PID)" + kill $PID +fi + +echo "Terminated" diff --git a/run/tor.opts.default.sh b/run/tor.opts.default.sh new file mode 100644 index 0000000..04d9020 --- /dev/null +++ b/run/tor.opts.default.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# PulseAudio process file location +PA_PID="$HOME/.config/pulse/`hostname`-runtime/pid" + +# VNC port exposed +EXTERNAL_PORT_VNC=5801 + +# PulseAudio port exposed +EXTERNAL_PORT_PULASE_AUDIO=4000 + +# Width of display +DISPLAY_WIDTH=1426 + +# Height of display +DISPLAY_HEIGHT=897 + +# Local folder to map inside VM, appears as /app/host +SHARED_LOCAL_FOLDER="host" + +# Docker Image +DOCKER_IMAGE_TAG="davidnewcomb/tor-browser" + +# PulseAudio needs the IP of your host to connect +# Darwin +#HOST_IP=$(ifconfig | grep broadcast | awk '{print $2}') +# Linux +#HOST_IP=$(hostname -I | awk '{print $1}')