Skip to content

Commit

Permalink
Merge pull request #113 from dnephin/do-improvements
Browse files Browse the repository at this point in the history
do: use GOLANG_VERSION arg
  • Loading branch information
dnephin committed May 16, 2020
2 parents 2ddfdd2 + daa669f commit 1b26a76
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions do
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,43 @@ go-mod-tidy() {
git diff --stat --exit-code go.mod go.sum
}

help[shell]='Run a shell in a golang docker container.
Env vars:
GOLANG_VERSION - the docker image tag used to build the image.
'
shell() {
local tag; tag="$(_docker-build-dev)"
local image; image="$(_docker-build-dev)"
docker run \
--tty --interactive --rm \
-v "$PWD:/work" \
-v ~/.cache/go-build:/root/.cache/go-build \
-v ~/go/pkg/mod:/go/pkg/mod \
-w /work \
"$tag" bash
"$image" \
"${@-bash}"
}

_docker-build-dev() {
set -e
local idfile=.plsdo/docker-build-dev-image-id
local idfile=".plsdo/docker-build-dev-image-id-${GOLANG_VERSION-default}"
local dockerfile=Dockerfile
local tag=gotest.tools/gotestsum/builder
if [ -f "$idfile" ] && [ "$dockerfile" -ot "$idfile" ]; then
echo "$tag"
cat "$idfile"
return 0
fi

mkdir -p .plsdo
>&2 docker build \
--iidfile "$idfile" \
--file "$dockerfile" \
--tag "$tag" \
--build-arg "UID=$UID" \
--build-arg GOLANG_VERSION \
--target "dev" \
.plsdo
echo "$tag"
cat "$idfile"
}

_plsdo_run "$@"

0 comments on commit 1b26a76

Please sign in to comment.