Skip to content

Commit

Permalink
Test distillery release
Browse files Browse the repository at this point in the history
  • Loading branch information
dbstratta committed Jan 31, 2018
1 parent e244eb2 commit 69dda2f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 8 deletions.
23 changes: 20 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM elixir:1.6.1
FROM elixir:1.6.1 AS builder

LABEL name="slack_quiet"
LABEL version="1.0.0"
LABEL maintainer="[email protected]"

ARG APP_NAME=slack_quiet

ENV MIX_ENV=${MIX_ENV:-prod}
ENV REPLACE_OS_VARS=true

# Install the hex package manager.
RUN mix local.hex --force
Expand All @@ -24,6 +27,20 @@ RUN mix deps.get --only prod
# Bundle app source.
COPY . .

RUN mix compile
RUN mix do deps.compile, compile

RUN mix release --env=prod --verbose \
&& mv _build/prod/rel/${APP_NAME} /opt/release \
&& mv /opt/release/bin/${APP_NAME} /opt/release/bin/start_server

FROM alpine:latest

RUN apk update && apk --no-cache --update add bash openssl-dev

ENV MIX_ENV=prod REPLACE_OS_VARS=true

WORKDIR /opt/app

COPY --from=builder /opt/release .

CMD ["mix", "phx.server"]
CMD ["/opt/app/bin/start_server", "foreground"]
7 changes: 4 additions & 3 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use Mix.Config
# which you typically run after static files are built.
config :slack_quiet, SlackQuietWeb.Endpoint,
load_from_system_env: true,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
http: [port: "${PORT}"],
url: [host: "${HOST}", port: "${PORT}"],
server: true

# Do not print debug messages in production
config :logger, level: :info
Expand Down Expand Up @@ -61,4 +62,4 @@ config :logger, level: :info

# Finally import the config/prod.secret.exs
# which should be versioned separately.
config :slack_quiet, SlackQuietWeb.Endpoint, secret_key_base: System.get_env("SECRET_KEY_BASE")
config :slack_quiet, SlackQuietWeb.Endpoint, secret_key_base: "${SECRET_KEY_BASE}"
6 changes: 4 additions & 2 deletions lib/slack_silence_web/controllers/slash_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defmodule SlackQuietWeb.SlashController do

@valid_locations ~w(hq brooklyn)

@locations_names %{"hq" => "HQ", "brooklyn" => "Brooklyn"}

@command_doc """
*usage:* `/quiet location floor`
Expand Down Expand Up @@ -90,8 +92,8 @@ defmodule SlackQuietWeb.SlashController do
defp send_delayed_response(response_url, [location | [floor]]) do
response = %{
response_type: "in_channel",
username: "Quiet Bot",
text: "<!here> Someone is asking for silence in #{location}. Floor: #{floor}."
text:
"<!here> Someone is asking for silence in #{@locations_names[location]}. Floor: #{floor}."
}

headers = ["Content-Type": "application/json"]
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ defmodule SlackQuiet.Mixfile do
{:cowboy, "~> 1.0"},
{:poison, "~> 3.1.0"},
{:httpoison, "~> 1.0.0"},
{:distillery, "~> 1.5.2", runtime: false},
{:credo, "~> 0.8.10", only: [:dev, :test], runtime: false}
]
end
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [], [], "hexpm"},
"credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
"distillery": {:hex, :distillery, "1.5.2", "eec18b2d37b55b0bcb670cf2bcf64228ed38ce8b046bb30a9b636a6f5a4c0080", [:mix], [], "hexpm"},
"gettext": {:hex, :gettext, "0.14.0", "1a019a2e51d5ad3d126efe166dcdf6563768e5d06c32a99ad2281a1fa94b4c72", [], [], "hexpm"},
"hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.0.0", "1f02f827148d945d40b24f0b0a89afe40bfe037171a6cf70f2486976d86921cd", [], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down
53 changes: 53 additions & 0 deletions rel/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,
# This sets the default release built by `mix release`
default_release: :default,
# This sets the default environment used by `mix release`
default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/configuration.html


# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
# If you are running Phoenix, you should make sure that
# server: true is set and the code reloader is disabled,
# even in dev mode.
# It is recommended that you build with MIX_ENV=prod and pass
# the --env flag to Distillery explicitly if you want to use
# dev mode.
set dev_mode: true
set include_erts: false
set cookie: :"vmyKjbpnM;t^*^AYBupmId*&<W?W*J@[o[qlA$wvO:}M(?&W.B/yMN>93qX5(mLA"
end

environment :prod do
set include_erts: true
set include_src: false
set cookie: :"j<]RSn.M1W,gD26hRz=_qLnb6)L<^]]w_vyUiAmo8`~`NqdD4;6C`?$/LmkI*2n:"
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :slack_quiet do
set version: current_version(:slack_quiet)
set applications: [
:runtime_tools
]
end

0 comments on commit 69dda2f

Please sign in to comment.