mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
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.
This commit is contained in:
parent
353c99db2d
commit
e3f42ee277
18
Dockerfile
18
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"]
|
||||
|
Loading…
Reference in New Issue
Block a user