Repository navigation
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
105 lines (85 loc) · 4.55 KB
/
Copy pathDockerfile.alpine
File metadata and controls
105 lines (85 loc) · 4.55 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Manticore on Alpine (musl). The same four stages as the Debian `Dockerfile`,
# and deliberately a SEPARATE file: apk and apt do not parametrise into one
# sensible build, and the interesting differences here are not package names.
#
# docker build -f Dockerfile.alpine --target toolchain -t manticore-toolchain:alpine .
# bash tools/docker/run_tests.sh --alpine
#
# A supported target: ci.yml builds and runs the suite on it per push (both
# arches), gate.yml adds difftest, and the release publishes `:<v>-alpine` and
# the `linux-musl` tarballs — all through the same `toolchain` and `base` stages
# below. musl loses only a few `glob` constants (`GLOB_BRACE`, `GLOB_ONLYDIR`)
# and the LFS64 aliases. It is also the shape a statically linked, truly
# portable output binary would take once the compiler grows `-static`.
ARG ALPINE_TAG=3.23
FROM alpine:${ALPINE_TAG} AS base
# clang assembles the IR; gcc is here for `cc`, the link driver, and it brings
# musl-dev's crt files with it. pkgconf provides pkg-config, pcre2-dev provides
# pcre2-config, curl-dev provides curl-config — the three probes Main.php runs.
# /etc/services ships in alpine-baselayout, so there is no netbase to add.
# The last line is what a first musl run costs, and none of it is guesswork —
# each package is one cluster of suite failures:
# tzdata -> /usr/share/zoneinfo, which TzInfo.php reads directly. Alpine
# ships no tz database at all, so every date_* case failed.
# icu-dev -> prelude/intl.php binds ICU (`icuuc` / `icui18n`), linked
# dynamically; its headers give the symbol-version suffix.
# icu-data-full -> icu-libs pulls only icu-data-en (English locales, a few
# converters); every other locale, zone name and codepage
# fell back to root and the intl_* cases diverged.
# libxml2-dev -> prelude/xml.php binds libxml2 through FFI (`#[Library('xml2')]`),
# and the dev package is what provides the linkable .so.
# NOT gnu-libiconv: musl keeps iconv inside libc (so no `-liconv`, as on glibc),
# and php on Alpine answers from musl's too — //TRANSLIT included, which musl
# does not have. The oracle is the host's php, so the binary uses the host's iconv.
RUN apk add --no-cache \
clang lld gcc musl-dev binutils \
pcre2-dev openssl-dev zlib-dev curl-dev sqlite-dev pkgconf \
bash file make curl ca-certificates \
tzdata libxml2-dev icu-dev icu-data-full
RUN clang --version | head -1 && cc --version | head -1 \
&& pcre2-config --libs8 && pkg-config --libs openssl \
&& curl-config --libs && pkg-config --libs sqlite3 && pkg-config --libs icu-uc icu-i18n
# uid 1000, matching the Debian image: running as root would make is_writable()
# of a 0400 file answer true and quietly disagree with the recorded expectations.
RUN adduser -D -u 1000 -s /bin/bash manticore \
&& mkdir -p /build \
&& chown -R manticore:manticore /build
WORKDIR /build
USER manticore
CMD ["/bin/bash"]
# ---- + PHP 8.5, the seed interpreter and the difftest oracle ----
# Alpine 3.23 carries php85 in the main repository, so this needs no third-party
# source — the one place musl is EASIER than Debian, where php comes from sury.
FROM base AS toolchain
# Alpine splits php far finer than Debian does, and the split is not cosmetic:
# `php85` alone has no ctype (the oracle and the Zend-hosted dev tools die on
# `ctype_digit()` without it). Everything below `mbstring` is what Debian's
# php8.5-cli bundles and Alpine does not.
USER root
RUN apk add --no-cache \
php85 php85-mbstring php85-curl php85-pdo_sqlite php85-intl \
php85-ctype php85-tokenizer php85-openssl php85-phar \
php85-session php85-posix php85-iconv php85-fileinfo \
&& ln -sf /usr/bin/php85 /usr/local/bin/php
RUN php --version \
&& php -r 'exit(function_exists("ctype_digit") ? 0 : 1);' \
&& php -r 'exit(function_exists("curl_init") ? 0 : 1);' \
&& php -r 'exit(extension_loaded("pdo_sqlite") ? 0 : 1);'
USER manticore
# ---- build the compiler from source ----
FROM toolchain AS build
COPY --chown=manticore:manticore . /build/manticore
WORKDIR /build/manticore
RUN rm -rf bin/manticore lib tests/aot/tmp \
&& bin/build
ENV PATH="/build/manticore/bin:${PATH}"
CMD ["/bin/bash"]
# ---- what a user runs ----
FROM base AS runtime
COPY --from=build /build/manticore/bin/manticore /opt/manticore/bin/manticore
COPY --from=build /build/manticore/lib /opt/manticore/lib
ENV PATH="/opt/manticore/bin:${PATH}"
WORKDIR /work
RUN manticore version
USER manticore
CMD ["manticore", "--help"]