Skip to content

Commit

Permalink
highly optimized elixir container builds
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Mar 1, 2020
1 parent a0710a7 commit 0717b9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
FROM "elixir:1.10.1-alpine"

ARG MIX_ENV=dev
ENV MIX_ENV=$MIX_ENV

WORKDIR /code/

RUN mix local.hex --force && mix local.rebar --force
RUN echo "y" | mix local.hex --if-missing && echo "y" | mix local.rebar --if-missing

ADD ["mix.lock", "mix.exs", "/code/"]

RUN mix deps.get && MIX_ENV=test mix deps.compile && \
MIX_ENV=$MIX_ENV mix deps.compile

ADD ["config", "lib", "priv", "/code/"]

RUN MIX_ENV=$MIX_ENV mix compile

COPY ["mix.lock", "mix.exs", "/code/"]
ADD ["test", "/code/"]

RUN mix deps.get
RUN MIX_ENV=test mix compile && MIX_ENV=$MIX_ENV mix compile

ADD . /code/

RUN mix compile
RUN MIX_ENV=test mix compile && MIX_ENV=$MIX_ENV mix compile

CMD ["/bin/sh"]

Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
build:
context: .
dockerfile: Dockerfile
cache_from:
- inakri/paper_trail:$CIRCLE_BRANCH
environment:
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
Expand All @@ -35,6 +37,3 @@ networks:
backend_network:
driver: bridge

# cache_from:
# - $BASE_IMAGE
# - $BACKEND_IMAGE_CACHE

0 comments on commit 0717b9c

Please sign in to comment.