summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Goodman <wagoodman@users.noreply.github.com>2019-07-27 14:19:21 -0400
committerGitHub <noreply@github.com>2019-07-27 14:19:21 -0400
commit943392389ccb832e7e828a028a942b5a724d9011 (patch)
tree3f8ab8e98b685032707c9352a71f616741938d2e
parent66bc1c2cb4e6a4a5afed481d74955cb2c14dafaf (diff)
parent6fbc5542f29cdacb55c0b9f9129340a0c40566bb (diff)
Merge pull request #214 from wagoodman/add-alpine-image
Update alpine based image
-rw-r--r--.goreleaser.yml26
-rw-r--r--Dockerfile2
-rw-r--r--Dockerfile.full15
-rw-r--r--Dockerfile.slim3
-rw-r--r--Makefile2
-rw-r--r--image/docker_image.go5
-rw-r--r--utils/docker.go6
7 files changed, 55 insertions, 4 deletions
diff --git a/.goreleaser.yml b/.goreleaser.yml
index 93a5343..262d671 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -14,6 +14,19 @@ builds:
dockers:
-
binary: dive
+ dockerfile: Dockerfile.slim
+ image_templates:
+ - "wagoodman/dive:{{ .Tag }}-slim"
+ - "wagoodman/dive:v{{ .Major }}-slim"
+ - "wagoodman/dive:v{{ .Major }}.{{ .Minor }}-slim"
+ - "wagoodman/dive:slim"
+ - "quay.io/wagoodman/dive:{{ .Tag }}-slim"
+ - "quay.io/wagoodman/dive:v{{ .Major }}-slim"
+ - "quay.io/wagoodman/dive:v{{ .Major }}.{{ .Minor }}-slim"
+ - "quay.io/wagoodman/dive:slim"
+ -
+ binary: dive
+ dockerfile: Dockerfile
image_templates:
- "wagoodman/dive:{{ .Tag }}"
- "wagoodman/dive:v{{ .Major }}"
@@ -23,7 +36,18 @@ dockers:
- "quay.io/wagoodman/dive:v{{ .Major }}"
- "quay.io/wagoodman/dive:v{{ .Major }}.{{ .Minor }}"
- "quay.io/wagoodman/dive:latest"
-
+ -
+ binary: dive
+ dockerfile: Dockerfile.full
+ image_templates:
+ - "wagoodman/dive:{{ .Tag }}-full"
+ - "wagoodman/dive:v{{ .Major }}-full"
+ - "wagoodman/dive:v{{ .Major }}.{{ .Minor }}-full"
+ - "wagoodman/dive:full"
+ - "quay.io/wagoodman/dive:{{ .Tag }}-full"
+ - "quay.io/wagoodman/dive:v{{ .Major }}-full"
+ - "quay.io/wagoodman/dive:v{{ .Major }}.{{ .Minor }}-full"
+ - "quay.io/wagoodman/dive:full"
archive:
format: tar.gz
diff --git a/Dockerfile b/Dockerfile
index 2405c29..5aa204a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,3 +1,3 @@
-FROM alpine:3.9
+FROM alpine:3.10
COPY dive /
ENTRYPOINT ["/dive"]
diff --git a/Dockerfile.full b/Dockerfile.full
new file mode 100644
index 0000000..6369ced
--- /dev/null
+++ b/Dockerfile.full
@@ -0,0 +1,15 @@
+FROM alpine:3.10
+
+ARG DOCKER_CLI_VERSION="19.03.1"
+ENV DOWNLOAD_URL="https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLI_VERSION.tgz"
+
+RUN apk --update add curl \
+ && mkdir -p /tmp/download \
+ && curl -L $DOWNLOAD_URL | tar -xz -C /tmp/download \
+ && mv /tmp/download/docker/docker /usr/local/bin/ \
+ && rm -rf /tmp/download \
+ && apk del curl \
+ && rm -rf /var/cache/apk/*
+
+COPY dive /
+ENTRYPOINT ["/dive"]
diff --git a/Dockerfile.slim b/Dockerfile.slim
new file mode 100644
index 0000000..a5bd8da
--- /dev/null
+++ b/Dockerfile.slim
@@ -0,0 +1,3 @@
+FROM scratch
+COPY dive /
+ENTRYPOINT ["/dive"]
diff --git a/Makefile b/Makefile
index e31f316..58de9a7 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ run-large: build
./build/$(BIN) amir20/clashleaders:latest
build:
- go build -o build/$(BIN)
+ CGO_ENABLED=0 go build -o build/$(BIN)
release: test-coverage validate
./.scripts/tag.sh
diff --git a/image/docker_image.go b/image/docker_image.go
index 5cb004f..7545b2f 100644
--- a/image/docker_image.go
+++ b/image/docker_image.go
@@ -100,6 +100,11 @@ func (image *dockerImageAnalyzer) Fetch() (io.ReadCloser, error) {
}
_, _, err = image.client.ImageInspectWithRaw(ctx, image.id)
if err != nil {
+
+ if !utils.IsDockerClientAvailable() {
+ return nil, fmt.Errorf("cannot find docker client executable")
+ }
+
// don't use the API, the CLI has more informative output
fmt.Println("Image not available locally. Trying to pull '" + image.id + "'...")
err = utils.RunDockerCmd("pull", image.id)
diff --git a/utils/docker.go b/utils/docker.go
index 22bf4c7..b5b9c1c 100644
--- a/utils/docker.go
+++ b/utils/docker.go
@@ -6,9 +6,13 @@ import (
"strings"
)
+func IsDockerClientAvailable() bool {
+ _, err := exec.LookPath("docker")
+ return err == nil
+}
+
// RunDockerCmd runs a given Docker command in the current tty
func RunDockerCmd(cmdStr string, args ...string) error {
-
allArgs := cleanArgs(append([]string{cmdStr}, args...))
cmd := exec.Command("docker", allArgs...)