Skip to content

Commit

Permalink
Improve Dockerfile: update base image and optimize image size (#2649)
Browse files Browse the repository at this point in the history
Also, drop ineffectual flags from configure.
  • Loading branch information
itchyny authored Jul 4, 2023
1 parent 12ce4e3 commit 2270e20
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 53 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
- name: Build
run: |
autoreconf -i
./configure --disable-dependency-tracking \
--disable-silent-rules \
./configure \
--disable-docs \
--disable-maintainer-mode \
--disable-valgrind \
Expand Down Expand Up @@ -96,8 +95,7 @@ jobs:
- name: Build
run: |
autoreconf -i
./configure --disable-dependency-tracking \
--disable-silent-rules \
./configure \
--disable-docs \
--disable-maintainer-mode \
--disable-valgrind \
Expand Down Expand Up @@ -156,8 +154,7 @@ jobs:
shell: msys2 {0}
run: |
autoreconf -i
./configure --disable-dependency-tracking \
--disable-silent-rules \
./configure \
--disable-docs \
--disable-maintainer-mode \
--disable-valgrind \
Expand Down Expand Up @@ -203,8 +200,7 @@ jobs:
- name: Create dist
run: |
autoreconf -i
./configure --disable-dependency-tracking \
--disable-silent-rules \
./configure \
--disable-docs \
--disable-maintainer-mode \
--disable-valgrind \
Expand Down
72 changes: 27 additions & 45 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,36 @@
FROM debian:9
FROM debian:12-slim AS builder

ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8

COPY . /app
RUN apt-get update \
&& apt-get install -y \
build-essential \
autoconf \
libtool \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# get dependencies, build, and remove anything we don't need for running jq.
# valgrind seems to have trouble with pthreads TLS so it's off.
WORKDIR /app
COPY . /app
RUN autoreconf -i \
&& ./configure \
--disable-docs \
--disable-maintainer-mode \
--disable-valgrind \
--with-oniguruma=builtin \
--enable-static \
--enable-all-static \
--prefix=/usr/local \
&& make -j$(nproc) \
&& make check \
&& make install-strip

RUN apt-get update && \
apt-get install -y \
build-essential \
autoconf \
libtool \
git \
bison \
flex \
python3 \
python3-pip \
wget && \
pip3 install pipenv && \
(cd /app/docs && pipenv sync) && \
(cd /app && \
git submodule init && \
git submodule update && \
autoreconf -i && \
./configure --disable-valgrind --enable-all-static --prefix=/usr/local && \
make -j8 && \
make check && \
make install ) && \
(cd /app/modules/oniguruma && \
make uninstall ) && \
(cd /app && \
make distclean ) && \
apt-get purge -y \
build-essential \
autoconf \
libtool \
bison \
git \
flex \
python3 \
python3-pip && \
apt-get autoremove -y && \
rm -rf /app/modules/oniguruma/* && \
rm -rf /app/modules/oniguruma/.git && \
rm -rf /app/modules/oniguruma/.gitignore && \
rm -rf /var/lib/apt/lists/* /var/lib/gems
FROM scratch

ENTRYPOINT ["/usr/local/bin/jq"]
CMD []
COPY --from=builder /app/AUTHORS /app/COPYING /usr/local/bin/jq /
RUN ["/jq", "--version"]
ENTRYPOINT ["/jq"]

0 comments on commit 2270e20

Please sign in to comment.