Skip to content

Commit 9d740c2

Browse files
committed
Create a final build stage with just the libs and bins
Copy the necessary libraries and binaries from the build stage into a final stage on debian:bullseye-slim. That source code and build tools (gcc) aren't being carried around unnecessarily. This cuts the image size from about 1.5 GB to 180 MB.
1 parent 7ab24e0 commit 9d740c2

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

Dockerfile

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,34 @@ RUN ./autogen.sh && ./configure
2222
RUN make -j4
2323
RUN make install
2424

25-
# Expose binaries
26-
ENV PATH /usr/local/src/hdt-cpp/libhdt/tools:$PATH
25+
FROM debian:bullseye-slim
2726

28-
# reset WORKDIR
29-
WORKDIR /
27+
# Install runtime dependencies
28+
RUN apt update; \
29+
apt install -y --no-install-recommends \
30+
libserd-0-0 \
31+
; \
32+
rm -rf /var/lib/apt/lists/*;
3033

31-
# Default command
32-
CMD ["/bin/echo", "Available commands: rdf2hdt hdt2rdf hdtSearch"]
34+
# Copy in libraries and binaries from build stage.
35+
COPY --from=build \
36+
/usr/local/lib/libcds* \
37+
/usr/local/lib/libhdt* \
38+
/usr/local/lib/
39+
COPY --from=build \
40+
/usr/local/lib64/libstdc++.* \
41+
/usr/local/lib64/
42+
COPY --from=build \
43+
/usr/local/bin/hdt2rdf \
44+
/usr/local/bin/hdtInfo \
45+
/usr/local/bin/hdtSearch \
46+
/usr/local/bin/modifyHeader \
47+
/usr/local/bin/rdf2hdt \
48+
/usr/local/bin/replaceHeader \
49+
/usr/local/bin/searchHeader \
50+
/usr/local/bin/
3351

52+
# Add /usr/local/lib to LD_LIBRARY_PATH.
53+
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH
54+
55+
CMD ["/bin/echo", "Available commands: rdf2hdt hdt2rdf hdtSearch"]

0 commit comments

Comments
 (0)