Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Docker image size from 165 MB to 32.8 MB #131

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
FROM elixir:1.5.2-alpine
FROM elixir:1.5.2-alpine AS builder

ENV APP_NAME poxa
ENV MIX_ENV prod

RUN apk --update add bash git erlang-xmerl erlang-crypto erlang-sasl && rm -rf /var/cache/apk/*
RUN apk --no-cache add git erlang-xmerl erlang-crypto erlang-sasl

COPY . /source
WORKDIR /source

RUN mix local.hex --force && mix local.rebar --force
RUN mix deps.get
RUN mix compile
RUN mix do \
local.hex --force, \
local.rebar --force, \
deps.get, \
compile
RUN echo "" > config/poxa.prod.conf
RUN mix release
RUN mkdir -p /app/$APP_NAME
WORKDIR /app/$APP_NAME
RUN tar xzf /source/_build/prod/rel/$APP_NAME/releases/*/$APP_NAME.tar.gz

RUN mkdir /app && cp -r _build/prod/rel/$APP_NAME /app && rm -rf /source

FROM alpine:3.6

ENV APP_NAME poxa
ENV MIX_ENV prod

RUN apk --no-cache add bash openssl

COPY --from=builder /app /app

CMD /app/$APP_NAME/bin/$APP_NAME foreground
3 changes: 1 addition & 2 deletions rel/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ environment :dev do
end

environment :prod do
set include_erts: false
set include_erts: true
set include_src: false
set cookie: :"xR=}b(ZcHU8M1Lu&642.m{u{O)H]WD>[&&_5t8FW3t5mxy4nw=de~;lEbw*?EFXC"
end
Expand All @@ -30,4 +30,3 @@ release :poxa do
]
plugin Conform.ReleasePlugin
end