-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
72 lines (63 loc) · 2.76 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
# syntax=docker/dockerfile:1.3
# requires buildx/buildkit-backend
# build and fetch statically linked dependencies
FROM alpine:latest as builder
ARG TARGETPLATFORM
RUN apk add alpine-sdk curl jq
WORKDIR /runit
ARG RUNIT_VER=2.1.2
RUN \
curl -OL http://smarden.org/runit/runit-${RUNIT_VER}.tar.gz && \
tar -xzpf runit-${RUNIT_VER}.tar.gz && \
cd admin/runit-${RUNIT_VER}/ && \
echo 'gcc -no-pie -static' > src/conf-ld && \
./package/compile && ./package/check && \
chmod +x command/*
WORKDIR /jq
ARG JQ_VER=jq-1.6
# no arm builds are supplied, so we build from source
RUN \
if [ -z "${TARGETPLATFORM}" ]; then \
TARGETPLATFORM="$(uname -m)" ; \
fi ; \
if [ -z "${TARGETPLATFORM##*arm64*}" -o -z "${TARGETPLATFORM##*aarch64*}" ]; then \
echo "building jq from source for ARM"; \
apk add git libtool automake autoconf && \
git clone https://github.com/stedolan/jq jq_source && cd jq_source && \
git checkout ${JQ_VER} && \
git submodule update --init --recursive && \
autoreconf -fi && \
./configure --with-oniguruma=builtin --disable-maintainer-mode && \
make LDFLAGS=-all-static && \
make check && \
cp jq ../jq ; \
else \
curl -L $(curl -L https://api.github.com/repos/stedolan/jq/releases/tags/${JQ_VER} | jq -r '.assets[] | select(.name | match(".*linux.*64")) | .browser_download_url') > jq && \
chmod +x jq ; \
fi
WORKDIR /tini
ARG TINI_VER=v0.19.0
RUN \
if [ -z "${TARGETPLATFORM}" ]; then \
TARGETPLATFORM="$(uname -m)" ; \
fi ; \
if [ -z "${TARGETPLATFORM##*arm64*}" -o -z "${TARGETPLATFORM##*aarch64*}" ]; then \
echo "selecting tini for ARM"; \
export TINI_ARCH_SELECTOR='^tini-static-arm64$' ; \
else \
export TINI_ARCH_SELECTOR='^tini-static-muslc-amd64$' ; \
fi && \
curl -L $(curl -L https://api.github.com/repos/krallin/tini/releases/tags/${TINI_VER} | jq --arg ARCH "${TINI_ARCH_SELECTOR}" -r '.assets[] | select(.name | match($ARCH)) | .browser_download_url') > tini && \
chmod +x tini
WORKDIR /opt/fission/bin
ADD fission .
RUN \
chmod +x fission && \
cp /jq/jq . && \
cp /tini/tini . && \
cp /runit/admin/runit-${RUNIT_VER}/command/* .
WORKDIR /
# build distribution container
FROM scratch
WORKDIR /
COPY --from=builder /opt/fission/bin /opt/fission/bin