-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Dockerfile
140 lines (127 loc) · 4.13 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
ARG BUILD_OS
ARG BUILD_BASE
FROM ${BUILD_OS}:${BUILD_BASE} AS builder
ARG BUILD_OS
ARG BUILD_BASE
RUN set -eux; \
echo "Building for: ${BUILD_OS}"; \
if [ "${BUILD_OS}" = "alpine" ]; then \
apk add --update --no-cache \
binutils-dev \
build-base \
cmake \
git \
curl-dev \
curl-static \
libdw \
openssl-dev \
ninja-build \
python3 \
zlib-dev \
elfutils-dev \
libstdc++-dev \
; \
elif [ "${BUILD_OS}" = "debian" ]; then \
apt-get update; \
apt-get install -y --no-install-recommends --no-install-suggests \
binutils-dev \
build-essential \
cmake \
git \
libcurl4-openssl-dev \
libdw-dev \
# Alpine: bundled in binutils-dev
libiberty-dev \
libssl-dev \
ninja-build \
python3 \
zlib1g-dev \
libelf-dev \
libstdc++-12-dev \
; \
fi
ADD . /src/
RUN set -eux; \
mkdir /src/build; \
cd /src/build; \
if [ "${BUILD_OS}" = "alpine" ]; then \
export PATH="$PATH:/usr/lib/ninja-build/bin/"; \
fi; \
cmake -G 'Ninja' ..; \
cmake --build .; \
cmake --build . --target install;
ARG BUILD_OS
ARG BUILD_BASE
FROM ${BUILD_OS}:${BUILD_BASE}
ARG BUILD_OS
ARG BUILD_BASE
# For metadata
ARG RELEASE_VERSION
ARG VCS_REF
ARG BUILD_DATE
COPY --from=builder /usr/local/bin/kcov* /usr/local/bin/
COPY --from=builder /usr/local/share/doc/kcov /usr/local/share/doc/kcov
RUN set -eux; \
echo "Building for: ${BUILD_OS}"; \
if [ "${BUILD_OS}" = "alpine" ]; then \
apk add --update --no-cache \
bash \
libcurl \
libdw \
zlib \
libgcc \
libstdc++ \
# libbfd.so
binutils-dev \
# To avoid changing the value of --python-parser
python3 \
; \
elif [ "${BUILD_OS}" = "debian" ]; then \
apt-get update; \
apt-get install -y --no-install-recommends --no-install-suggests \
libcurl4 \
libdw1 \
zlib1g \
libbfd-dev \
# To avoid changing the value of --python-parser
python-is-python3 \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
fi; \
# Write a test script
printf '#!/usr/bin/env bash\nif [[ true ]]; then\necho "Hello, kcov!"\nfi' > /tmp/test-executable.sh; \
# Test kcov
kcov --include-pattern=/tmp/test-executable.sh /tmp/coverage /tmp/test-executable.sh; \
# Display
cat /tmp/coverage/test-executable.sh/coverage.json; \
# Make assertions
grep -q -c '"percent_covered": "100.00"' /tmp/coverage/test-executable.sh/coverage.json; \
grep -q -c '"total_lines": 2' /tmp/coverage/test-executable.sh/coverage.json; \
# Cleanup
rm -r /tmp/coverage /tmp/test-executable.sh;
# Metadata
LABEL org.label-schema.vendor="Kcov" \
org.label-schema.url="https://github.com/SimonKagstrom/kcov#readme" \
org.label-schema.name="The docker image for kcov" \
org.label-schema.description="A docker image for kcov" \
org.label-schema.version=${RELEASE_VERSION} \
org.label-schema.vcs-url="https://github.com/SimonKagstrom/kcov.git" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.docker.schema-version="1.0" \
\
com.docker.extension.publisher-url="https://github.com/SimonKagstrom" \
\
org.opencontainers.image.title="The docker image for kcov" \
org.opencontainers.image.description="A docker image for kcov" \
org.opencontainers.image.authors="https://github.com/SimonKagstrom" \
org.opencontainers.image.url="https://github.com/SimonKagstrom/kcov#readme" \
org.opencontainers.image.documentation="https://github.com/SimonKagstrom/kcov#readme" \
org.opencontainers.image.source="https://github.com/SimonKagstrom/kcov" \
org.opencontainers.image.vendor="Kcov" \
org.opencontainers.image.licenses="GPL-2.0-only AND MIT AND (GPL-2.0-only OR MIT)" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.version=${RELEASE_VERSION} \
org.opencontainers.image.revision=${VCS_REF}
CMD ["/usr/local/bin/kcov"]