-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update static Linux build to MozJPEG 4.0.
Statically link with libc too so it works on Alpine and other non-glibc based distros and add a SOURCE_DATE_EPOCH so the build is reproducible.
- Loading branch information
Showing
4 changed files
with
41 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
FROM debian:8-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install autoconf libtool nasm libpng-dev automake pkg-config build-essential wget \ | ||
-yq --no-install-suggests --no-install-recommends --force-yes | ||
|
||
WORKDIR /src | ||
RUN wget --no-check-certificate https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz -O mozjpeg-3.3.1.tar.gz | ||
RUN tar -xzvf mozjpeg-3.3.1.tar.gz | ||
WORKDIR /src/mozjpeg-3.3.1 | ||
|
||
RUN autoreconf -fiv \ | ||
&& ./configure LDFLAGS=-static libpng_LIBS='/usr/lib/x86_64-linux-gnu/libpng12.a -lz' --enable-static --disable-shared \ | ||
&& make -j8 | ||
FROM docker.io/library/alpine:latest | ||
RUN apk --update --no-cache upgrade && apk add --no-cache \ | ||
build-base \ | ||
nasm \ | ||
cmake \ | ||
ninja \ | ||
curl \ | ||
libpng-dev libpng-static \ | ||
zlib-dev zlib-static | ||
RUN adduser -G wheel -D builder | ||
WORKDIR /home/builder | ||
USER builder | ||
ENV mozjpeg_version 4.0.0 | ||
# 2020-11-13 UTC | ||
ENV SOURCE_DATE_EPOCH 1605225600 | ||
RUN mkdir bin | ||
COPY /build.sh build.sh | ||
RUN ["/bin/sh", "build.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
curl -fLO "https://github.com/mozilla/mozjpeg/archive/v${mozjpeg_version}.tar.gz" | ||
tar xf "v${mozjpeg_version}.tar.gz" | ||
|
||
export CFLAGS='-pipe -flto -no-pie' | ||
export LDFLAGS='-flto -no-pie -static -static-libgcc' | ||
|
||
# This unsets CMAKE_SHARED_LIBRARY_LINK_C_FLAGS inside CMakeLists.txt, | ||
# which is necessary to build a static binary. It can't be unset from the CLI. | ||
sed -E -i.bk '/set\(LIBJPEG_TURBO_V/i\ | ||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)' "mozjpeg-$mozjpeg_version"/CMakeLists.txt | ||
|
||
cmake -S "mozjpeg-$mozjpeg_version" -B build -G Ninja \ | ||
-D ENABLE_SHARED=OFF \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/local \ | ||
-D CMAKE_FIND_LIBRARY_SUFFIXES=.a \ | ||
-D CMAKE_LINK_SEARCH_END_STATIC=1 -D CMAKE_LINK_SEARCH_START_STATIC=1 | ||
|
||
cd build && ninja | ||
strip cjpeg-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.