From 31e594980b267a6be499c61d5a0ec2c08484dde7 Mon Sep 17 00:00:00 2001 From: Alejandro Gaston Alvarez Franceschi Date: Tue, 26 Jan 2021 00:22:17 -0800 Subject: [PATCH] Multistage docker (#396) Summary: **Original Issue**: This dicussion started [here](https://github.com/facebookresearch/flashlight/pull/225#issuecomment-727635347) The main point of this PR is to update dockerfiles to use a multistage build, reducing build time and final image size. But it also adds to small but important features: - `.dockerignore` to avoid passing unnecessary files to the build context - `ccache` support to CMake > I'm sure that most of the packages installed with apt on some builds and especially on the final image can be removed. But you know better which ones to take out. This would further reduce the final image size | image | build-time | size | |--------------------------------|------------|--------| | cpu-base-consolidation-latest | 454.4s | 4.76GB | | cpu-latest | 433.6s | 3.38GB | | cuda-base-consolidation-latest | 970.3s | 13.7GB | | cuda-latest | 440.3s | 9.31GB | Pull Request resolved: https://github.com/facebookresearch/flashlight/pull/396 Reviewed By: jacobkahn Differential Revision: D25820782 Pulled By: tlikhomanenko fbshipit-source-id: eef3d0550dee862d9bbfb24aa06f716c92ef75e8 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dabaa81e..0abe02cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ include(CTest) include(CMakeDependentOption) # ----------------------------- Setup ----------------------------- +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") +endif() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") set(CMAKE_CXX_STANDARD 14)