Merge pull request #214 from wagoodman/add-alpine-image

Update alpine based image
This commit is contained in:
Alex Goodman 2019-07-27 14:19:21 -04:00 committed by GitHub
commit 943392389c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 4 deletions

View File

@ -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

View File

@ -1,3 +1,3 @@
FROM alpine:3.9
FROM alpine:3.10
COPY dive /
ENTRYPOINT ["/dive"]

15
Dockerfile.full Normal file
View File

@ -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"]

3
Dockerfile.slim Normal file
View File

@ -0,0 +1,3 @@
FROM scratch
COPY dive /
ENTRYPOINT ["/dive"]

View File

@ -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

View File

@ -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)

View File

@ -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...)