-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (63 loc) · 1.51 KB
/
Copy pathDockerfile
File metadata and controls
83 lines (63 loc) · 1.51 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
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
FROM ubuntu:24.04 AS builder
ARG GIT_CRYPTO_VER=0.8.0
ARG BUILD_STATIC=true
COPY sources* /src
RUN <<EOF
#!/usr/bin/env bash
set -Eeuo pipefail
echo "Install deps..."
if ! apt-get update; then
echo "APT update error"
exit 1
fi
if ! apt install -y g++ make build-essential libssl-dev; then
echo "APT install error"
exit 1
fi
if ! mkdir -p /build; then
echo "mkdir error"
exit 1
fi
echo "Consume sources..."
if [ ! -d "/src" ] || [ -z "$(ls -A /src)" ]; then
echo "Sources dir is not mounted. Clone repo..."
echo "Install git..."
if ! apt install -y git; then
echo "APT install git error"
exit 1
fi
echo "Clone branch ${GIT_CRYPTO_VER}..."
if ! git clone --branch ${GIT_CRYPTO_VER} --single-branch https://github.com/AGWA/git-crypt.git /build; then
echo "git clone error"
exit 1
fi
else
echo "Sources dir mounted. Copy..."
if ! cp -R /src/* /build; then
echo "cannot copy source"
exit 1
fi
fi
flags="-DOPENSSL_API_COMPAT=0x30000000L"
if [[ "${BUILD_STATIC}" == "true" ]]; then
flags="$flags -static -ldl"
fi
echo "Build with additional flags: $flags"
cd /build
if ! CXXFLAGS="$flags" make build; then
echo "Build failed"
exit 1
fi
ldd_out=""
if ! ldd_out="$(ldd /build/git-crypt 2>&1)"; then
echo ""
fi
if grep -q "not a dynamic executable" <<<"$ldd_out"; then
echo "git-crypt is static!"
else
echo "git-crypt is NOT static!"
fi
echo "You can extract binary from /git-crypt path"
EOF
FROM scratch
COPY --from=builder /build/git-crypt /git-crypt