Skip to content

Instantly share code, notes, and snippets.

@timbuchwaldt
Last active May 12, 2019 11:56
Show Gist options
  • Save timbuchwaldt/cfa7da0d9f90d89e6755b40859850433 to your computer and use it in GitHub Desktop.
Save timbuchwaldt/cfa7da0d9f90d89e6755b40859850433 to your computer and use it in GitHub Desktop.
#!/bin/sh -eu
rm -rf .depscache
mkdir .depscache
rsync -r --exclude=.depscache . .depscache
pushd .depscache
find . -type f ! -wholename '*mix.*' -a -type f ! -wholename "*config/*" -delete
find . -type d -empty -delete
popd
DOCKER_BUILDKIT=1 docker build .
FROM elixir as build
RUN mix local.hex --force && mix local.rebar --force
ADD .depscache/ /app/
RUN cd /app && mix deps.get && mix deps.compile && MIX_ENV=test mix deps.compile && MIX_ENV=prod mix deps.compile
FROM elixir
RUN mix local.hex --force && mix local.rebar --force
ADD . /app
COPY --from=build /app/_build /app/_build
COPY --from=build /app/deps /app/deps
RUN cd /app && mix compile
@timbuchwaldt
Copy link
Author

This could greatly benefit from caching deps during runs so stuff isn't fetched multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment