Skip to content

Commit

Permalink
Docker script for building the 'prod' app
Browse files Browse the repository at this point in the history
  • Loading branch information
romange committed Sep 3, 2018
1 parent 661cf1a commit a182dfe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -1,3 +1,4 @@
third_party/*
boost_1_67_0/*
docker/*
build-*
23 changes: 16 additions & 7 deletions docker/bin_build.Dockerfile
@@ -1,4 +1,4 @@
FROM romange/cpp-dev18 as build_third_party
FROM romange/cpp-dev18 as third_party

# To allow caching third_party libs via "minimal" build.
# We do not use ARG here, not even reference it here because otherwise it would cause cache misses
Expand All @@ -10,11 +10,20 @@ RUN cmake -L -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DONLY
RUN ninja -j4 protobuf_project glog_project sparsehash_project gperf_project zstd_project \
evhtp_project lz4_project xxhash_project

FROM build_third_party
# Now we use ARGs.
ARG TARGET
FROM third_party as src
COPY ./ /src/
RUN mkdir /pkg && cmake -L -DONLY_THIRD_PARTY=OFF -GNinja /src

FROM src as bin
# Now really building the target. Previous containers will be reused between the builds.
COPY ./ /src/
RUN cmake -L -DONLY_THIRD_PARTY=OFF -GNinja /src
RUN ninja -j4 $TARGET
ARG TARGET

RUN ninja -j4 $TARGET && strip $TARGET && mv $TARGET /pkg/
RUN ldd -r /pkg/$TARGET | grep "/build/third_party" | awk '{print $3}' | \
while read n; do cp -nH $n /pkg/; done

FROM romange/u18prod
ARG TARGET
RUN echo $TARGET
COPY --from=bin /pkg/ /app/
RUN ldconfig /app

0 comments on commit a182dfe

Please sign in to comment.