Created
September 17, 2018 12:58
-
-
Save eugenestarchenko/05cf61b6d8c738fbfdc148f187f6b0ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| kcachegrind=$(docker images --format '{{.Repository}}' |grep 'kcachegrind') | |
| if [[ -z "$kcachegrind" ]]; then | |
| docker_build_directory=/tmp/Dockerfile | |
| mkdir -p $docker_build_directory | |
| cd $docker_build_directory | |
| # 如果 uid 不是 1000, 需要这里改正. | |
| # The env variable and the folder /tmp/.X11-unix are needed to share your X11 process with the container. | |
| # If you meet the following error when trying to launch it "Error: cannot open display: :0", | |
| # use the following command: xhost +. | |
| cat <<'HEREDOC' > $docker_build_directory/Dockerfile | |
| FROM ubuntu:16.04 | |
| ENV uid 1000 | |
| ENV gid 1000 | |
| ENV DEBIAN_FRONTEND noninteractive | |
| ENV QT_X11_NO_MITSHM 1 | |
| RUN echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse \n\ | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse \n\ | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse \n\ | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse \n\ | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse \n\ | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse \n\ | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse \n\ | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse \n\ | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse \n\ | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse \n\ | |
| ' > /etc/apt/sources.list | |
| RUN apt-get update && apt-get install -y --no-install-recommends kcachegrind graphviz && rm -rf /var/lib/apt/lists/* | |
| RUN useradd developer -m -s /bin/bash | |
| USER developer | |
| ENTRYPOINT ["kcachegrind"] | |
| HEREDOC | |
| docker build -t kcachegrind -f $docker_build_directory/Dockerfile . | |
| cd $OLDPWD | |
| fi | |
| working_dir=$PWD | |
| [ "$1" ] && file=$(readlink -e $1) | |
| docker run --rm -e DISPLAY \ | |
| -v /tmp/.X11-unix:/tmp/.X11-unix \ | |
| -v "$working_dir":"$working_dir" \ | |
| -v /tmp:/tmp \ | |
| kcachegrind \ | |
| $file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment