-
Notifications
You must be signed in to change notification settings - Fork 111
/
Dockerfile-minimized
78 lines (63 loc) · 2.11 KB
/
Dockerfile-minimized
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
#
# Dockerfile to build and run ugrep in a container (production/minimized environment).
#
# This file creates the bare essentials to run ugrep in a container, with nothing else.
# It's a minimized environment, with no development tools, no git, no make, etc.
# It's perfect for running ugrep in a compact container.
#
# Build the ugrep image:
# $ docker build -f Dockerfile-minimized -t ugrep .
#
# Execute ugrep in the container (The / of the host is accessible in /mnt directory in the container):
# $ docker run -v /:/mnt -it ugrep --help
# or run bash in the container instead:
# $ docker run -v /:/mnt --entrypoint /bin/bash -it ugrep
# $ ugrep --help
FROM ubuntu AS builder
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
ca-certificates \
pkg-config \
make \
vim \
git \
clang \
wget \
unzip \
libpcre2-dev \
libz-dev \
libbz2-dev \
liblzma-dev \
liblz4-dev \
libzstd-dev \
libbrotli-dev
WORKDIR /ugrep
# Clone ugrep from GitHub
RUN git clone --single-branch --depth=1 https://github.com/Genivia/ugrep /ugrep
# Local build of ugrep
# If you want to build ugrep from a local source, uncomment the following line:
# ADD . /ugrep
RUN autoreconf -fi
RUN ./build.sh
# Create a tarball with the necessary libraries to run ugrep in a minimized environment
# Some large libraries are excluded to keep the image size small
RUN tar -czvf /libs.tar.gz \
--exclude=/lib/x86_64-linux-gnu/libclang* \
--exclude=/lib/x86_64-linux-gnu/libicudata* \
--exclude=/lib/x86_64-linux-gnu/libtsan* \
/lib/x86_64-linux-gnu/*.so* /lib64/*
# Use clean new image (alpine is small and compact compared to ubuntu)
FROM alpine AS production
# Copy libraries from the builder image
COPY --from=builder /libs.tar.gz /
RUN tar -C / -xzvf /libs.tar.gz
RUN rm /libs.tar.gz
# TODO: find a way to make `make install` work instead of calling install manually
WORKDIR /ugrep
COPY --from=builder /ugrep/bin/ug* ./
RUN install -d /usr/local/bin/ && install -D /ugrep/* /usr/local/bin/
RUN ugrep --version
ENTRYPOINT [ "ugrep" ]