Skip to content

Commit

Permalink
Merge branch 'norelease/better-docker-build'
Browse files Browse the repository at this point in the history
* norelease/better-docker-build:
  FEATURE: Make `docker build` more robust 💪
  • Loading branch information
ivanilves committed Apr 11, 2018
2 parents f6d916a + 0949e8d commit 39d63b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ script:
- if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then make blackbox-integration-test; fi
- make lint
- make vet
- make docker-image DOCKER_TAG=release

after_script:
- sudo killall -v dockerd

before_deploy:
- make release
- make docker-image DOCKER_TAG=release

deploy:
provider: script
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ FROM scratch
COPY ca-certificates.crt /etc/ssl/certs/
# * compiled lstags binary [we assume you've run `make build GOOS=linux` before]
COPY ./dist/assets/lstags-linux/lstags /lstags
# Make sure we [are statically linked and] can run inside a scratch-based container
RUN ["/lstags", "--version"]
ENTRYPOINT ["/lstags"]
CMD ["--help"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ fail-on-errors:

docker-image: DOCKER_REPO:=ivanilves/lstags
docker-image: DOCKER_TAG:=latest
docker-image: GOOS:=linux
docker-image: build
docker-image:
@docker image build -t ${DOCKER_REPO}:${DOCKER_TAG} .
@docker image build --no-cache -t ${DOCKER_REPO}:${DOCKER_TAG} .

build: NAME=$(shell test "${GOOS}" = "windows" && echo 'lstags.exe' || echo 'lstags')
build:
@if [[ -z "${GOOS}" ]]; then go build -ldflags '-s -w' -a -tags netgo -installsuffix netgo; fi
@if [[ -z "${GOOS}" ]]; then go build -ldflags '-d -s -w' -a -tags netgo -installsuffix netgo; fi
@if [[ -n "${GOOS}" ]]; then mkdir -p dist/assets/lstags-${GOOS}; GOOS=${GOOS} go build -ldflags '-s -w' -a -tags netgo -installsuffix netgo -o dist/assets/lstags-${GOOS}/${NAME}; fi

xbuild:
Expand Down
6 changes: 2 additions & 4 deletions util/fix/fix.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package fix

import (
"os/user"
"os"
"strings"
)

// Path resolves "~" intro the real home path
func Path(path string) string {
u, _ := user.Current()

return strings.Replace(path, "~", u.HomeDir, 1)
return strings.Replace(path, "~", os.Getenv("HOME"), 1)
}

0 comments on commit 39d63b4

Please sign in to comment.