From 353c99db2dd994c0570a9a25c4b3cc50953d1c88 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Wed, 5 Jun 2019 08:21:09 -0400 Subject: [PATCH 1/4] Add a Dockerfile that builds the CLI tool --- .dockerignore | 1 + Dockerfile | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..94143827e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c9356908c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM haskell:8.6 as build +WORKDIR /build +RUN cabal new-update +COPY . /build +RUN cabal new-build semantic:exe:semantic + +# A fake `install` target until we can get `cabal new-install` to work +RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /semantic + +FROM debian:stretch +RUN apt-get update && \ + apt-get install -y \ + libgmp10 \ + && \ + apt-get autoremove -y && \ + apt-get clean -y && \ + rm -rf /var/lib/apt/lists/* +COPY --from=build /semantic /usr/local/bin/semantic +ENTRYPOINT ["/usr/local/bin/semantic"] From e3f42ee27743626801996ddc1afb0446736b8c56 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Wed, 5 Jun 2019 09:58:25 -0400 Subject: [PATCH 2/4] Compile dependencies separately So that they can be more aggressively cached by Docker! The Docker hub will take advantage of this, too, which should make our autobuilds faster. --- Dockerfile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c9356908c..d0768abcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,26 @@ FROM haskell:8.6 as build WORKDIR /build RUN cabal new-update + +# Build our upstream dependencies after copying in only enough to tell cabal +# what they are. This will make these layers cache better even as we change the +# code of semantic itself. +COPY semantic.cabal /build/ +COPY cabal.project /build/ +COPY semantic-core/semantic-core.cabal /build/semantic-core/ +COPY vendor /build/vendor +RUN cabal new-build --only-dependencies + +# Once the dependencies are built, copy in the rest of the code and compile +# semantic itself. COPY . /build RUN cabal new-build semantic:exe:semantic # A fake `install` target until we can get `cabal new-install` to work -RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /semantic +RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /usr/local/bin/semantic +# Create a fresh image containing only the compiled CLI program, so that the +# image isn't bulked up by all of the extra build state. FROM debian:stretch RUN apt-get update && \ apt-get install -y \ @@ -15,5 +29,5 @@ RUN apt-get update && \ apt-get autoremove -y && \ apt-get clean -y && \ rm -rf /var/lib/apt/lists/* -COPY --from=build /semantic /usr/local/bin/semantic +COPY --from=build /usr/local/bin/semantic /usr/local/bin/semantic ENTRYPOINT ["/usr/local/bin/semantic"] From 79fa92e9e6e7e937708929f48ac463db1adcb8c1 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Wed, 5 Jun 2019 10:38:51 -0400 Subject: [PATCH 3/4] Bump minimum `base` version to 4.12.0.0. This should hopefully provide a more informative error message when someone attempts to build the project with too old of a GHC. --- semantic-core/semantic-core.cabal | 2 +- semantic.cabal | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/semantic-core/semantic-core.cabal b/semantic-core/semantic-core.cabal index b608ad41f..05cf971b2 100644 --- a/semantic-core/semantic-core.cabal +++ b/semantic-core/semantic-core.cabal @@ -35,7 +35,7 @@ library -- other-modules: -- other-extensions: build-depends: algebraic-graphs ^>= 0.3 - , base >= 4.11 && < 5 + , base >= 4.12 && < 5 , containers ^>= 0.6 , directory ^>= 1.3 , filepath ^>= 1.4 diff --git a/semantic.cabal b/semantic.cabal index 8ede2c97a..f0d84bd0d 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -41,7 +41,7 @@ common haskell -- as caret-operator bounds relative to a version in Stackage. -- These are currently pinned to lts-13.13. common dependencies - build-depends: base >= 4.8 && < 5 + build-depends: base >= 4.12 && < 5 , aeson ^>= 1.4.2.0 , algebraic-graphs ^>= 0.3 , async ^>= 2.2.1 @@ -273,7 +273,7 @@ library -- Custom Prelude , Prologue - build-depends: base >= 4.8 && < 5 + build-depends: base >= 4.12 && < 5 , ansi-terminal ^>= 0.8.2 , array ^>= 0.5.3.0 , attoparsec ^>= 0.13.2.2 From 4f947565acf0ba983e709ed9fc12ca34f58f4233 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Wed, 5 Jun 2019 13:22:45 -0400 Subject: [PATCH 4/4] Edits from tclem --- Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d0768abcb..6099b3b17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,10 @@ RUN cabal new-update # Build our upstream dependencies after copying in only enough to tell cabal # what they are. This will make these layers cache better even as we change the # code of semantic itself. -COPY semantic.cabal /build/ -COPY cabal.project /build/ -COPY semantic-core/semantic-core.cabal /build/semantic-core/ -COPY vendor /build/vendor +COPY semantic.cabal . +COPY cabal.project . +COPY semantic-core/semantic-core.cabal ./semantic-core/ +COPY vendor ./vendor RUN cabal new-build --only-dependencies # Once the dependencies are built, copy in the rest of the code and compile @@ -21,7 +21,8 @@ RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /usr/local/bin/se # Create a fresh image containing only the compiled CLI program, so that the # image isn't bulked up by all of the extra build state. -FROM debian:stretch +FROM debian:stretch-slim + RUN apt-get update && \ apt-get install -y \ libgmp10 \ @@ -29,5 +30,7 @@ RUN apt-get update && \ apt-get autoremove -y && \ apt-get clean -y && \ rm -rf /var/lib/apt/lists/* + COPY --from=build /usr/local/bin/semantic /usr/local/bin/semantic + ENTRYPOINT ["/usr/local/bin/semantic"]