-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (52 loc) · 2.01 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
# syntax=docker/dockerfile:1
# bump: libxml2 /LIBXML2_VERSION=([\d.]+)/ https://gitlab.gnome.org/GNOME/libxml2.git|^2
# bump: libxml2 after ./hashupdate Dockerfile LIBXML2 $LATEST
# bump: libxml2 link "ChangeLog" https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/NEWS
ARG LIBXML2_VERSION=2.10.3
ARG LIBXML2_URL="https://gitlab.gnome.org/GNOME/libxml2/-/archive/v${LIBXML2_VERSION}/libxml2-v${LIBXML2_VERSION}.tar.bz2"
ARG LIBXML2_SHA256=302bbb86400b8505bebfbf7b3d1986e9aa05073198979f258eed4be481ff5f83
# Must be specified
ARG ALPINE_VERSION
FROM alpine:${ALPINE_VERSION} AS base
FROM base AS download
ARG LIBXML2_URL
ARG LIBXML2_SHA256
ARG WGET_OPTS="--retry-on-host-error --retry-on-http-error=429,500,502,503 -nv"
WORKDIR /tmp
RUN \
apk add --no-cache --virtual download \
coreutils wget tar && \
wget $WGET_OPTS -O libxml2.tar.bz2 "$LIBXML2_URL" && \
echo "$LIBXML2_SHA256 libxml2.tar.bz2" | sha256sum --status -c - && \
mkdir libxml2 && \
tar xf libxml2.tar.bz2 -C libxml2 --strip-components=1 && \
rm libxml2.tar.bz2 && \
apk del download
FROM base AS build
COPY --from=download /tmp/libxml2/ /tmp/libxml2/
WORKDIR /tmp/libxml2/build
ARG CFLAGS="-O3 -s -static-libgcc -fno-strict-overflow -fstack-protector-all -fPIC"
RUN \
apk add --no-cache --virtual build \
build-base cmake pkgconf && \
cmake -S .. -B . \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D LIBXML2_WITH_ICONV=OFF \
-D LIBXML2_WITH_LZMA=OFF \
-D LIBXML2_WITH_PYTHON=OFF \
-D LIBXML2_WITH_ZLIB=OFF \
&& \
cmake --build . && \
cmake --install . && \
# Sanity tests
pkg-config --exists --modversion --path libxml-2.0 && \
ar -t /usr/local/lib/libxml2.a && \
readelf -h /usr/local/lib/libxml2.a && \
# Cleanup
apk del build
FROM scratch
ARG LIBXML2_VERSION
COPY --from=build /usr/local/lib/pkgconfig/libxml-2.0.pc /usr/local/lib/pkgconfig/libxml-2.0.pc
COPY --from=build /usr/local/lib/libxml2.a /usr/local/lib/libxml2.a
COPY --from=build /usr/local/include/libxml2/ /usr/local/include/libxml2/