-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (83 loc) · 3.26 KB
/
Dockerfile
File metadata and controls
92 lines (83 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# syntax=docker/dockerfile:1
FROM ghcr.io/linuxserver/baseimage-alpine:edge AS build-stage
# set version label
ARG BUILD_DATE
ARG VERSION
ARG APP_VERSION
LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thespad"
LABEL org.opencontainers.image.source="https://github.com/thespad/docker-dive"
LABEL org.opencontainers.image.url="https://github.com/thespad/docker-dive"
ARG GOCACHE=/tmp \
GOOS=linux \
CGO_ENABLED=0
RUN \
ARCH=$(uname -m) && \
apk add --update --no-cache --virtual=build-dependencies \
build-base \
git \
go && \
apk add -U --upgrade --no-cache \
grep && \
echo "**** install docker cli ****" && \
mkdir -p /tmp/docker && \
if [ -z ${DOCKER_RELEASE+x} ]; then \
DOCKER_RELEASE=$(curl -sX GET "https://api.github.com/repos/docker/cli/tags" | \
jq -r '.[] | .name' | grep -P -v -m 1 '(rc|beta|alpha)' | sed 's/^.//'); \
fi && \
if [ $ARCH != "riscv64" ]; then \
curl -s -o \
/tmp/docker.tar.gz -L \
"https://download.docker.com/linux/static/stable/${ARCH}/docker-${DOCKER_RELEASE}.tgz" && \
tar xf \
/tmp/docker.tar.gz -C \
/tmp/docker/ --strip-components=1 && \
mv /tmp/docker/docker /usr/local/bin; \
else \
echo "**** Fetching cli source from https://github.com/docker/cli/archive/refs/tags/v${DOCKER_RELEASE}.tar.gz ****" && \
curl -sLo /tmp/docker/cli-${DOCKER_RELEASE}.tar.gz "https://github.com/docker/cli/archive/refs/tags/v${DOCKER_RELEASE}.tar.gz" && \
cd /tmp/docker && \
tar -zxf cli-${DOCKER_RELEASE}.tar.gz && \
cd cli-${DOCKER_RELEASE} && \
mkdir -p .gopath/src/github.com/docker && \
export GOPATH=/tmp/docker/cli-${DOCKER_RELEASE}/.gopath && \
ln -s `pwd` .gopath/src/github.com/docker/cli && \
DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary && \
mv build/docker-linux-${ARCH} /usr/local/bin/docker; \
fi && \
echo "**** installed docker cli version ${DOCKER_RELEASE} ****" && \
echo "**** install dive ****" && \
mkdir -p /tmp/dive && \
if [ -z ${APP_VERSION+x} ]; then \
APP_VERSION=$(curl -sX GET "https://api.github.com/repos/wagoodman/dive/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
curl -s -o \
/tmp/dive.tar.gz -L \
"https://github.com/wagoodman/dive/archive/${APP_VERSION}.tar.gz" && \
tar xf \
/tmp/dive.tar.gz -C \
/tmp/dive/ --strip-components=1 && \
cd /tmp/dive && \
go build -o /usr/local/bin/dive && \
echo "**** installed dive version ${APP_VERSION} ****" && \
echo "**** clean up ****" && \
apk del --purge \
build-dependencies && \
rm -rf \
/tmp/* \
/root/go
FROM scratch
# set version label
ARG BUILD_DATE
ARG VERSION
ARG APP_VERSION
LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thespad"
LABEL org.opencontainers.image.source="https://github.com/thespad/docker-dive"
LABEL org.opencontainers.image.url="https://github.com/thespad/docker-dive"
LABEL org.opencontainers.image.description="A tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker/OCI image"
LABEL org.opencontainers.image.authors="thespad"
COPY --from=build-stage /usr/local/bin/dive /
COPY --from=build-stage /usr/local/bin/docker /usr/local/bin/docker
ENTRYPOINT ["/dive"]