Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit e3f42ee

Browse files
committed
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.
1 parent 353c99d commit e3f42ee

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Dockerfile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
FROM haskell:8.6 as build
22
WORKDIR /build
33
RUN cabal new-update
4+
5+
# Build our upstream dependencies after copying in only enough to tell cabal
6+
# what they are. This will make these layers cache better even as we change the
7+
# code of semantic itself.
8+
COPY semantic.cabal /build/
9+
COPY cabal.project /build/
10+
COPY semantic-core/semantic-core.cabal /build/semantic-core/
11+
COPY vendor /build/vendor
12+
RUN cabal new-build --only-dependencies
13+
14+
# Once the dependencies are built, copy in the rest of the code and compile
15+
# semantic itself.
416
COPY . /build
517
RUN cabal new-build semantic:exe:semantic
618

719
# A fake `install` target until we can get `cabal new-install` to work
8-
RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /semantic
20+
RUN cp $(find dist-newstyle -name semantic -type f -perm -u=x) /usr/local/bin/semantic
921

22+
# Create a fresh image containing only the compiled CLI program, so that the
23+
# image isn't bulked up by all of the extra build state.
1024
FROM debian:stretch
1125
RUN apt-get update && \
1226
apt-get install -y \
@@ -15,5 +29,5 @@ RUN apt-get update && \
1529
apt-get autoremove -y && \
1630
apt-get clean -y && \
1731
rm -rf /var/lib/apt/lists/*
18-
COPY --from=build /semantic /usr/local/bin/semantic
32+
COPY --from=build /usr/local/bin/semantic /usr/local/bin/semantic
1933
ENTRYPOINT ["/usr/local/bin/semantic"]

0 commit comments

Comments
 (0)