-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
55 lines (40 loc) · 1.39 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
FROM alpine:latest as builder
RUN set -x \
&& apk add --no-cache make file gcc musl-dev
COPY . /tmp/mustpl
WORKDIR /tmp/mustpl
ARG VERSION="undefined"
# compile
RUN make version="$VERSION"
# running tests is not required, but it's strongly recommended
RUN make test
# print out some info about the binary file
RUN set -x \
&& ./mustpl --version \
&& ./mustpl --help \
&& ls -lh ./mustpl \
&& file ./mustpl
WORKDIR /tmp/rootfs
# prepare the rootfs for scratch
RUN set -x \
&& mkdir -p ./bin ./etc \
&& mv /tmp/mustpl/mustpl ./bin/mustpl \
&& echo 'nobody:x:10001:10001::/nonexistent:/sbin/nologin' > ./etc/passwd \
&& echo 'nogroup:x:10001:' > ./etc/group
# use empty filesystem
FROM scratch as runtime
ARG VERSION="undefined"
LABEL \
# Docs: <https://github.com/opencontainers/image-spec/blob/master/annotations.md>
org.opencontainers.image.title="mustpl" \
org.opencontainers.image.description="Logic-less CLI templating tool - mustpl" \
org.opencontainers.image.url="https://github.com/tarampampam/mustpl" \
org.opencontainers.image.source="https://github.com/tarampampam/mustpl" \
org.opencontainers.image.vendor="tarampampam" \
org.opencontainers.version="$VERSION" \
org.opencontainers.image.licenses="MIT"
# use the unprivileged user
USER 10001:10001
# import from builder
COPY --from=builder /tmp/rootfs /
ENTRYPOINT ["/bin/mustpl"]