Skip to content

Instantly share code, notes, and snippets.

@tiagopog
Last active April 3, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagopog/ec0e5cd7ea90261fdf8e029c86248daa to your computer and use it in GitHub Desktop.
Save tiagopog/ec0e5cd7ea90261fdf8e029c86248daa to your computer and use it in GitHub Desktop.
Elixir - Deploy with mix_docker, Distillery, Docker and k8s
# rel/config.exs
use Mix.Releases.Config,
default_release: :myapp,
default_environment: Mix.env
environment :dev do
set dev_mode: true
set include_erts: false
set include_system_libs: false
set cookie: :dev
end
environment :prod do
set include_erts: true
set include_system_libs: true
set cookie: :prod
end
# Regular app:
release :foo do
set version: current_version(:foo)
end
# Umbrella app:
release :myapp do
set version: "0.1.0"
set applications: [:app_a, app_b: :permanent, some_dep: :load]
end
FROM elixir:1.4.2
ENV DEBIAN_FRONTEND=noninteractive
ENV HOME=/opt/app/ TERM=xterm
# Install Hex+Rebar
RUN mix local.hex --force && \
mix local.rebar --force
WORKDIR /opt/app
ENV MIX_ENV=prod REPLACE_OS_VARS=true
# Cache elixir deps
COPY mix.exs mix.lock ./
RUN mix deps.get
COPY config ./config
RUN mix deps.compile
COPY . .
RUN mix release --env=prod
FROM elixir:1.4.2
ENV DEBIAN_FRONTEND=noninteractive
EXPOSE 8000
ENV PORT=8000 MIX_ENV=prod REPLACE_OS_VARS=true SHELL=/bin/bash
WORKDIR /app
COPY ./myapp.tar.gz ./
RUN tar xfz myapp.tar.gz
ENTRYPOINT ["bin/myapp"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment