-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (44 loc) · 1.77 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (44 loc) · 1.77 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
# syntax=docker/dockerfile:1
FROM alpine:latest AS builder
# install build dependencies (musl is Alpine's default libc)
RUN apk add --no-cache make file gcc musl-dev patch cmake wget tar
COPY . /src
WORKDIR /src
ARG APP_VERSION="0.0.0"
# build the binaries using gcc (Alpine already uses musl AFAIK)
RUN set -x \
&& make clean \
&& make CC=gcc APP_VERSION="$APP_VERSION" \
&& ./build/bin/httpcheck --help \
&& ./build/bin/httpscheck --help \
&& ./build/bin/portcheck --help \
&& ./build/bin/parallel --help \
&& ./build/bin/pidcheck --help \
&& ls -lh ./build/bin
WORKDIR /tmp/rootfs
# prepare the rootfs for scratch
RUN set -x \
&& mkdir -p ./bin ./etc \
&& mv /src/build/bin/httpcheck ./bin/httpcheck \
&& mv /src/build/bin/httpscheck ./bin/httpscheck \
&& mv /src/build/bin/portcheck ./bin/portcheck \
&& mv /src/build/bin/parallel ./bin/parallel \
&& mv /src/build/bin/pidcheck ./bin/pidcheck \
&& echo 'nobody:x:10001:10001::/nonexistent:/sbin/nologin' > ./etc/passwd \
&& echo 'nogroup:x:10001:' > ./etc/group
# use empty filesystem
FROM scratch AS runtime
ARG APP_VERSION="0.0.0"
# docs: <https://github.com/opencontainers/image-spec/blob/master/annotations.md>
LABEL \
org.opencontainers.image.title="microcheck" \
org.opencontainers.image.description="Lightweight health check utilities for Docker containers" \
org.opencontainers.image.url="https://github.com/tarampampam/microcheck" \
org.opencontainers.image.source="https://github.com/tarampampam/microcheck" \
org.opencontainers.image.vendor="tarampampam" \
org.opencontainers.version="$APP_VERSION" \
org.opencontainers.image.licenses="MIT"
# use the unprivileged user
USER 10001:10001
# import from builder
COPY --from=builder /tmp/rootfs /