-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
93 lines (71 loc) · 1.78 KB
/
Dockerfile
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
93
ARG REGISTRY=docker.io/
ARG ALPINE_VERSION=edge
ARG UID=5355
ARG NPROC=
ARG DESTDIR=/out
ARG VARIANT=core
FROM ${REGISTRY}alpine:${ALPINE_VERSION} as builder
RUN set -eux; \
apk add \
--no-cache \
autoconf \
automake \
bison \
busybox-static \
flex \
gcc \
git \
musl-dev \
libtool \
make \
;
FROM builder as core-addon
ARG DESTDIR
RUN set -eux; \
mkdir -p ${DESTDIR}
FROM builder as busybox-addon
ARG DESTDIR
RUN set -eux; \
mkdir -p ${DESTDIR}/bin; \
/bin/busybox.static --install "${DESTDIR}/bin"
FROM ${VARIANT}-addon as selected-addon
FROM builder as runtime-rootfs
ARG DESTDIR
RUN set -eux; \
mkdir -p ${DESTDIR}/bin
FROM builder as jq-build
ARG JQ_VERSION=1.6
ARG JQ_GIT_PREFIX=https://github.com/stedolan
ARG JQ_GIT_TAG=jq-${JQ_VERSION}
ARG DESTDIR
ARG NPROC
RUN set -eux; \
git_opts=""; \
if [ -n "$NPROC" ]; then \
git_opts="-j${NPROC}"; \
fi; \
git clone --recursive $git_opts ${JQ_GIT_PREFIX}/jq src; \
cd src; \
# Strip the trailing '.0' if passed <major>.<minor>.0
PATCH=$(echo $JQ_VERSION | awk '{split($0,a,"."); print a[3]}'); \
if [ "$PATCH" = '0' ]; then \
# The upstream project tags their releases in a wierd way :(
JQ_GIT_TAG=jq-$(echo $JQ_VERSION | awk '{split($0,a,"."); print a[1]"."a[2]}'); \
fi; \
git reset --hard $JQ_GIT_TAG; \
autoreconf -fi; \
./configure \
--prefix="" \
--with-oniguruma=builtin \
--disable-docs \
; \
make -j${NPROC} LDFLAGS=-all-static; \
make install
FROM scratch
ARG DESTDIR
ARG UID
COPY --from=runtime-rootfs ${DESTDIR}/ /
COPY --from=jq-build ${DESTDIR}/bin/ /bin
COPY --from=selected-addon ${DESTDIR}/ /
USER $UID
CMD ["/bin/jq"]