Dockerfile.linux-static-builder 3.26 KB
Newer Older
Eric Timmons's avatar
Eric Timmons committed
1
2
# This Dockerfile builds an image with all neded dependencies to create static
# releases for Linux.
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

ARG sbcl_version=2.1.1
ARG daewok_signing_key=823DF61DEDB633B3DE7B2B7C181191EF9ACF6934
ARG alpine_version=3.13
ARG image_repo=clfoundation/sbcl

FROM $image_repo:$sbcl_version-alpine$alpine_version

WORKDIR /usr/local/src/

# Install prereqs
RUN set -x \
    && apk add --no-cache git ca-certificates curl openssl make gcc musl-dev linux-headers gnupg patch zlib-dev zlib-static

# Download the SBCL source code.
RUN set -x \
    && GNUPGHOME="$(mktemp -d)" \
    && export GNUPGHOME \
    && (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$SBCL_SIGNING_KEY" \
        || gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$SBCL_SIGNING_KEY" \
       ) \
    && curl -fsSL "https://downloads.sourceforge.net/project/sbcl/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-crhodes.asc" > "sbcl-${SBCL_VERSION}-crhodes.asc" \
    && gpg --batch --verify "sbcl-${SBCL_VERSION}-crhodes.asc" \
    && gpg --batch --decrypt "sbcl-${SBCL_VERSION}-crhodes.asc" > "sbcl-${SBCL_VERSION}-crhodes.txt" \
    && curl -fsSL "https://downloads.sourceforge.net/project/sbcl/sbcl/${SBCL_VERSION}/sbcl-${SBCL_VERSION}-source.tar.bz2" > "sbcl-${SBCL_VERSION}-source.tar.bz2" \
    && bunzip2 "sbcl-${SBCL_VERSION}-source.tar.bz2" \
    && grep "sbcl-${SBCL_VERSION}-source.tar" "sbcl-${SBCL_VERSION}-crhodes.txt" > "${SBCL_VERSION}-sum-file.txt" \
    && sha256sum -c "${SBCL_VERSION}-sum-file.txt" \
    && tar xf "sbcl-${SBCL_VERSION}-source.tar" \
    && pkill -9 gpg-agent \
    && pkill -9 dirmngr \
    && rm -rf "$GNUPGHOME"

WORKDIR /usr/local/src/sbcl-$SBCL_VERSION/

ARG daewok_signing_key

# Patch the source code.
RUN set -x \
    && GNUPGHOME="$(mktemp -d)" \
    && export GNUPGHOME \
    && (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$daewok_signing_key" \
        || gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$daewok_signing_key" \
       ) \
    # Remove the hardcoding of armv5 as target arch. Use the default provided
    # by the base image.
    && sed -i -e "s/CFLAGS += -marm -march=armv5/CFLAGS += -marm/" src/runtime/Config.arm-linux \
    && curl -fsSL "https://www.timmons.dev/static/patches/sbcl/$SBCL_VERSION/static-executable-support-v2.patch" > static-executable-support.patch \
    && curl -fsSL "https://www.timmons.dev/static/patches/sbcl/$SBCL_VERSION/static-executable-support-v2.patch.asc" > static-executable-support.patch.asc \
    && gpg --batch --verify static-executable-support.patch.asc static-executable-support.patch \
    && patch -p1 < static-executable-support.patch \
    && rm static-executable-support.patch static-executable-support.patch.asc \
    && echo "\"$SBCL_VERSION-static-executable-v2\"" > version.lisp-expr \
    && pkill -9 gpg-agent \
    && pkill -9 dirmngr \
    && rm -rf "$GNUPGHOME"
Eric Timmons's avatar
Eric Timmons committed
59

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Build it!
RUN set -x \
    && case "$(cat /etc/apk/arch)" in \
         armv7) SBCL_ARCH=arm;; \
         aarch64) SBCL_ARCH=arm64;; \
         x86_64) SBCL_ARCH=x86-64;; \
         *) echo "Unknown arch" >&2; exit 1;; \
       esac \
    && export SBCL_ARCH \
    && sh make.sh --with-sb-linkable-runtime --with-sb-prelink-linkage-table \
    && sh install.sh

RUN apk add --no-cache openssl-dev openssl-libs-static pkgconfig

WORKDIR /app