-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce Docker image size from 165 MB to 32.8 MB (#131)
Reduce Docker image size from 165 MB to 32.8 MB Using multi-stage build available from Docker 17.05 to avoid having any build artifacts.
- Loading branch information
Showing
2 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters