Skip to content

Instantly share code, notes, and snippets.

@NewbMiao
Last active December 24, 2019 12:52
Show Gist options
  • Save NewbMiao/f4340b483e3dfc057911cba8e7a37562 to your computer and use it in GitHub Desktop.
Save NewbMiao/f4340b483e3dfc057911cba8e7a37562 to your computer and use it in GitHub Desktop.
Cmd to run gotrace tool that compiled by go1.8. (docker pull newbmiao/gotrace1.8)
FROM divan/golang:gotrace
RUN go get -u github.com/divan/gotrace && cd $GOPATH/src/github.com/divan/gotrace && git checkout go18 && go install
RUN mv /go/bin/gotrace /usr/local/bin
EXPOSE 2000
ENTRYPOINT ["gotrace"]
#!/bin/bash
DOCKERPATH="https://git.io/JeQQM" #https://gist.github.com/NewbMiao/f4340b483e3dfc057911cba8e7a37562#file-dockerfile
IMAGETAG="divan/golang:gotrace1.8"
if [ $# -eq 0 ]; then
echo -e "Usage: Require go file pathname(some code enable trace goroutines)\n\
Shell : sh gotrace.sh goroutines.go"
exit;
fi
exist=$(docker images|grep gotrace1.8|wc -l)
if [ $exist -eq 0 ]; then
echo "build image $IMAGETAG"
{
workspace=$(cd $(dirname $0) && pwd -P)
cd $workspace
if [ ! -f "Dockerfile" ]; then
curl -o Dockerfile "$DOCKERPATH"
fi
docker build . -t $IMAGETAG
}
fi
docker run --rm -it -p 2000:2000 -v $PWD:/go $IMAGETAG $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment