Skip to content

Commit

Permalink
Use elixir 1.9 releases
Browse files Browse the repository at this point in the history
  • Loading branch information
mobileoverlord committed Jul 9, 2019
1 parent aa49036 commit 0e70f22
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 165 deletions.
1 change: 0 additions & 1 deletion apps/nerves_hub_api/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ config :nerves_hub_api, NervesHubAPIWeb.Endpoint,
config :logger, level: :debug

config :rollbax,
access_token: "${ROLLBAR_ACCESS_TOKEN}",
environment: to_string(Mix.env()),
enabled: true,
enable_crash_reports: true
3 changes: 1 addition & 2 deletions apps/nerves_hub_api/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule NervesHubAPI.Mixfile do
def project do
[
app: :nerves_hub_api,
version: "0.0.1",
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
Expand Down Expand Up @@ -42,7 +42,6 @@ defmodule NervesHubAPI.Mixfile do
{:plug, "~> 1.7"},
{:plug_cowboy, "~> 2.0"},
{:gettext, "~> 0.11"},
{:distillery, "~> 2.0"},
{:cowboy, "~> 2.1", override: true},
{:rollbax, "~> 0.10.0"},
{:jason, "~> 1.0"},
Expand Down
6 changes: 2 additions & 4 deletions apps/nerves_hub_api/rel/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ADD . /build
WORKDIR /build

RUN mix deps.clean --all && mix deps.get
RUN mix release --env=$MIX_ENV --name=nerves_hub_api
RUN mix release nerves_hub_api --overwrite

# Release Container
FROM nerveshub/runtime:alpine-3.9 as release
Expand All @@ -24,9 +24,7 @@ EXPOSE 443

WORKDIR /app

COPY --from=builder /build/_build/$MIX_ENV/rel/nerves_hub_api/releases/*/nerves_hub_api.tar.gz .
RUN tar xvfz nerves_hub_api.tar.gz > /dev/null && rm nerves_hub_api.tar.gz

COPY --from=builder /build/_build/$MIX_ENV/rel/nerves_hub_api/* ./
COPY --from=builder /build/rel/scripts/docker-entrypoint.sh .
COPY --from=builder /build/rel/scripts/s3-sync.sh .
COPY --from=builder /build/rel/scripts/ecs-cluster.sh .
Expand Down
1 change: 0 additions & 1 deletion apps/nerves_hub_device/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ config :nerves_hub_device, NervesHubDeviceWeb.Endpoint,
config :logger, level: :debug

config :rollbax,
access_token: "${ROLLBAR_ACCESS_TOKEN}",
environment: to_string(Mix.env()),
enabled: true,
enable_crash_reports: true
1 change: 0 additions & 1 deletion apps/nerves_hub_device/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ defmodule NervesHubDevice.Mixfile do
{:cowboy, "~> 2.0", override: true},
{:jason, "~> 1.0"},
{:gettext, "~> 0.11"},
{:distillery, "~> 2.0"},
{:rollbax, "~> 0.10.0"},
{:phoenix_client, "~> 0.7", only: :test},
{:websocket_client, "~> 1.3", only: :test},
Expand Down
5 changes: 2 additions & 3 deletions apps/nerves_hub_device/rel/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ADD . /build
WORKDIR /build

RUN mix deps.clean --all && mix deps.get
RUN mix release --env=$MIX_ENV --name=nerves_hub_device
RUN mix release nerves_hub_device --overwrite

# Release Container
FROM nerveshub/runtime:alpine-3.9 as release
Expand All @@ -20,8 +20,7 @@ EXPOSE 443

WORKDIR /app

COPY --from=builder /build/_build/$MIX_ENV/rel/nerves_hub_device/releases/*/nerves_hub_device.tar.gz .
RUN tar xvfz nerves_hub_device.tar.gz > /dev/null && rm nerves_hub_device.tar.gz
COPY --from=builder /build/_build/$MIX_ENV/rel/nerves_hub_device/* ./

COPY --from=builder /build/rel/scripts/docker-entrypoint.sh .
COPY --from=builder /build/rel/scripts/s3-sync.sh .
Expand Down
7 changes: 0 additions & 7 deletions apps/nerves_hub_web_core/config/prod.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use Mix.Config

config :ex_aws,
region: "${AWS_REGION}"

config :nerves_hub_web_core, NervesHubWebCore.Scheduler,
global: true,
jobs: [
Expand All @@ -21,10 +18,6 @@ config :nerves_hub_web_core, NervesHubWebCore.Scheduler,
]

config :nerves_hub_web_core, firmware_upload: NervesHubWebCore.Firmwares.Upload.S3
config :nerves_hub_web_core, NervesHubWebCore.Firmwares.Upload.S3, bucket: "${S3_BUCKET_NAME}"

config :nerves_hub_web_core, NervesHubWebCore.Firmwares.Transfer.S3Ingress,
bucket: "${S3_LOG_BUCKET_NAME}"

config :nerves_hub_web_core, NervesHubWebCore.CertificateAuthority,
host: "nerves-hub-ca.local",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ defmodule NervesHubWebCore.Release.Tasks do
@otp_app :nerves_hub_web_core
@start_apps [:logger, :ssl, :postgrex, :ecto_sql]

def migrate do
def migrate_and_seed do
init(@otp_app, @start_apps)

run_migrations_for(@otp_app)
run_seed_script("#{seed_path(@otp_app)}/seeds.exs")

stop()
end
Expand All @@ -20,14 +21,6 @@ defmodule NervesHubWebCore.Release.Tasks do
stop()
end

def seed do
init(@otp_app, @start_apps)

run_seed_script("#{seed_path(@otp_app)}/seeds.exs")

stop()
end

defp init(app, start_apps) do
IO.puts("Loading nerves_hub_web_core app for migrations...")
Application.load(app)
Expand Down
12 changes: 1 addition & 11 deletions apps/nerves_hub_www/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,21 @@ config :nerves_hub_www, NervesHubWWWWeb.Endpoint,
load_from_system_env: true,
server: true,
url: [host: "www.nerves-hub.org", port: 80],
secret_key_base: "${SECRET_KEY_BASE}",
force_ssl: [rewrite_on: [:x_forwarded_proto]],
live_view: [signing_salt: "${LIVE_VIEW_SIGNING_SALT}"]
force_ssl: [rewrite_on: [:x_forwarded_proto]]

config :nerves_hub_device, NervesHubDeviceWeb.Endpoint, server: false

config :nerves_hub_www, NervesHubWWWWeb.AccountController, allow_signups: false

# Do not print debug messages in production
config :logger, level: :debug

config :nerves_hub_www, NervesHubWWW.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "${SES_SERVER}",
port: "${SES_PORT}",
username: "${SMTP_USERNAME}",
password: "${SMTP_PASSWORD}",
# can be `:always` or `:never`
tls: :always,
# can be `true`
ssl: false,
retries: 1

config :rollbax,
access_token: "${ROLLBAR_ACCESS_TOKEN}",
environment: to_string(Mix.env()),
enabled: true,
enable_crash_reports: true
1 change: 0 additions & 1 deletion apps/nerves_hub_www/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ defmodule NervesHubWWW.MixProject do
{:hackney, "~> 1.9"},
{:bamboo, "~> 1.0"},
{:bamboo_smtp, "~> 1.5.0"},
{:distillery, "~> 2.0"},
{:rollbax, "~> 0.10.0"},
{:floki, "~> 0.20", only: [:test, :dev]},
{:jason, "~> 1.0"},
Expand Down
6 changes: 2 additions & 4 deletions apps/nerves_hub_www/rel/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ WORKDIR /build
COPY --from=deps /build/deps deps
COPY --from=assets /build/apps/nerves_hub_www/priv/static apps/nerves_hub_www/priv/static

RUN mix do phx.digest, release --env=$MIX_ENV --name=nerves_hub_www
RUN mix do phx.digest, release nerves_hub_www --overwrite

# Release Container
FROM nerveshub/runtime:alpine-3.9 as release
Expand All @@ -40,9 +40,7 @@ EXPOSE 443

ENV LOCAL_IPV4=127.0.0.1

COPY --from=builder /build/_build/$MIX_ENV/rel/nerves_hub_www/releases/*/nerves_hub_www.tar.gz .
RUN tar xvfz nerves_hub_www.tar.gz > /dev/null && rm nerves_hub_www.tar.gz

COPY --from=builder /build/_build/$MIX_ENV/rel/nerves_hub_www/* ./
COPY --from=builder /build/rel/scripts/docker-entrypoint.sh .
COPY --from=builder /build/rel/scripts/s3-sync.sh .
COPY --from=builder /build/rel/scripts/ecs-cluster.sh .
Expand Down
22 changes: 22 additions & 0 deletions config/releases.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Config

config :rollbax, access_token: System.fetch_env!("ROLLBAR_ACCESS_TOKEN")

config :nerves_hub_web_core, NervesHubWebCore.Firmwares.Upload.S3,
bucket: System.fetch_env!("S3_BUCKET_NAME")

config :nerves_hub_web_core, NervesHubWebCore.Firmwares.Transfer.S3Ingress,
bucket: System.fetch_env!("S3_LOG_BUCKET_NAME")

config :ex_aws, region: System.fetch_env!("AWS_REGION")

config :nerves_hub_www, NervesHubWWWWeb.Endpoint,
secret_key_base: System.fetch_env!("SECRET_KEY_BASE"),
live_view: [signing_salt: System.fetch_env!("LIVE_VIEW_SIGNING_SALT")]

config :nerves_hub_www, NervesHubWWW.Mailer,
adapter: Bamboo.SMTPAdapter,
server: System.fetch_env!("SES_SERVER"),
port: System.fetch_env!("SES_PORT"),
username: System.fetch_env!("SMTP_USERNAME"),
password: System.fetch_env!("SMTP_PASSWORD")
24 changes: 24 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule NervesHubUmbrella.MixProject do

def project do
[
version: "0.1.0",
apps_path: "apps",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand All @@ -11,6 +12,29 @@ defmodule NervesHubUmbrella.MixProject do
dialyzer: [
plt_add_apps: [],
ignore_warnings: "dialyzer.ignore-warnings"
],
releases: [
nerves_hub_www: [
steps: [:assemble],
include_executables_for: [:unix],
applications: [
nerves_hub_www: :permanent
]
],
nerves_hub_device: [
steps: [:assemble],
include_executables_for: [:unix],
applications: [
nerves_hub_device: :permanent
]
],
nerves_hub_api: [
steps: [:assemble],
include_executables_for: [:unix],
applications: [
nerves_hub_api: :permanent
]
]
]
]
end
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%{
"ansi_to_html": {:git, "https://github.com/jjcarstens/ansi_to_html", "7aa02d8c425e92d876616073e26af591c189ef76", []},
"artificery": {:hex, :artificery, "0.2.6", "f602909757263f7897130cbd006b0e40514a541b148d366ad65b89236b93497a", [:mix], [], "hexpm"},
"artificery": {:hex, :artificery, "0.4.2", "3ded6e29e13113af52811c72f414d1e88f711410cac1b619ab3a2666bbd7efd4", [:mix], [], "hexpm"},
"bamboo": {:hex, :bamboo, "1.0.0", "446525f74eb59022ef58bc82f6c91c8e4c5a1469ab42a7f9b37c17262f872ef0", [:mix], [{:hackney, "~> 1.12.1", [hex: :hackney, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"bamboo_smtp": {:hex, :bamboo_smtp, "1.5.0", "ebc4deb64a0ff88d05edc1e5f6fd77aea563cdbeac3fcb277666af96dff309e3", [:mix], [{:bamboo, "~> 1.0.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:gen_smtp, "~> 0.12.0", [hex: :gen_smtp, repo: "hexpm", optional: false]}], "hexpm"},
"bcrypt_elixir": {:hex, :bcrypt_elixir, "1.1.1", "6b5560e47a02196ce5f0ab3f1d8265db79a23868c137e973b27afef928ed8006", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"},
Expand All @@ -14,7 +14,7 @@
"db_connection": {:hex, :db_connection, "2.0.6", "bde2f85d047969c5b5800cb8f4b3ed6316c8cb11487afedac4aa5f93fd39abfa", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.7.0", "30d6b52c88541f9a66637359ddf85016df9eb266170d53105f02e4a67e00c5aa", [:mix], [], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.4", "71b42f5ee1b7628f3e3a6565f4617dfb02d127a0499ab3e72750455e986df001", [:mix], [{:erlex, "~> 0.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"distillery": {:hex, :distillery, "2.0.12", "6e78fe042df82610ac3fa50bd7d2d8190ad287d120d3cd1682d83a44e8b34dfb", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},
"distillery": {:hex, :distillery, "2.1.1", "f9332afc2eec8a1a2b86f22429e068ef35f84a93ea1718265e740d90dd367814", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "3.0.6", "d33ab5b3f7553a41507d4b0ad5bf192d533119c4ad08f3a5d63d85aa12117dc9", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_enum": {:hex, :ecto_enum, "1.2.0", "9ead3ee04efc4cb68a50560a9d9ebb665dd697f957f1c3df8e81bf863cf7a4e9", [:mix], [{:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm"},
Expand Down
83 changes: 0 additions & 83 deletions rel/config.exs

This file was deleted.

20 changes: 20 additions & 0 deletions rel/env.sh.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac

# Set the release to work across nodes. If using the long name format like
# the one below (my_app@127.0.0.1), you need to also uncomment the
# RELEASE_DISTRIBUTION variable below.
export RELEASE_COOKIE=${ERL_COOKIE}
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>@${LOCAL_IPV4}
export ELIXIR_ERL_OPTIONS="-kernel inet_dist_listen_min 9100 inet_dist_listen_max 9155 sync_nodes_timeout 5000 sync_nodes_optional \"${SYNC_NODES_OPTIONAL}\""
5 changes: 0 additions & 5 deletions rel/scripts/gc.sh

This file was deleted.

9 changes: 0 additions & 9 deletions rel/scripts/migrate-and-seed.sh

This file was deleted.

2 changes: 1 addition & 1 deletion rel/scripts/migration-overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"containerOverrides": [
{
"name": "nerves_hub_www",
"command": ["/app/bin/nerves_hub_www", "migrate"]
"command": ["/app/bin/nerves_hub_www", "eval", "NervesHubWebCore.Release.Tasks.migrate_and_seed()"]
}
]
}

0 comments on commit 0e70f22

Please sign in to comment.