Skip to content

Commit ab1529e

Browse files
authored
Merge pull request #226 from kinghuang/update-dockerfile
Upgrade base image gcc:bullseye and create optimized final image stage
2 parents 332a9cc + 76cd2c1 commit ab1529e

2 files changed

Lines changed: 59 additions & 34 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.dockerignore
2+
.git
3+
.gitignore
4+
.travis.yml
5+
Dockerfile
6+
README.md

Dockerfile

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,55 @@
1-
FROM gcc:6
2-
3-
WORKDIR /usr/local/src
4-
COPY . /usr/local/src/hdt-cpp/
5-
6-
# Install dependencies
7-
RUN apt-get update && apt-get -y install \
8-
build-essential \
9-
libraptor2-dev \
10-
#libserd-dev \
11-
autoconf \
12-
libtool \
13-
liblzma-dev \
14-
liblzo2-dev \
15-
zlib1g-dev
16-
17-
18-
# Install more recent serd
19-
RUN wget https://github.com/drobilla/serd/archive/v0.28.0.tar.gz \
20-
&& tar -xvzf *.tar.gz \
21-
&& rm *.tar.gz \
22-
&& cd serd-* \
23-
&& ./waf configure && ./waf && ./waf install
1+
FROM gcc:bullseye as build
2+
3+
# Install build dependencies
4+
RUN apt update; \
5+
apt install -y --no-install-recommends \
6+
autoconf \
7+
build-essential \
8+
liblzma-dev \
9+
liblzo2-dev \
10+
libraptor2-dev \
11+
libserd-dev \
12+
libtool \
13+
zlib1g-dev \
14+
; \
15+
rm -rf /var/lib/apt/lists/*;
16+
17+
WORKDIR /usr/local/src/hdt-cpp
18+
COPY . .
2419

2520
# Install HDT tools
26-
RUN cd hdt-cpp && ./autogen.sh && ./configure && make -j2
27-
28-
# Expose binaries
29-
ENV PATH /usr/local/src/hdt-cpp/libhdt/tools:$PATH
30-
31-
# reset WORKDIR
32-
WORKDIR /
33-
34-
# Default command
35-
CMD ["/bin/echo", "Available commands: rdf2hdt hdt2rdf hdtSearch"]
36-
21+
RUN ./autogen.sh && ./configure
22+
RUN make -j4
23+
RUN make install
24+
25+
FROM debian:bullseye-slim
26+
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/*;
33+
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/
51+
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 hdtInfo hdtSearch modifyHeader replaceHeader searchHeader"]

0 commit comments

Comments
 (0)