diff --git a/Dockerfile b/Dockerfile index 0557ac4..cad2d63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ RUN mix local.rebar --force # Set work directory WORKDIR /app +# Install dependencies +RUN mix deps.get + # Expose Phoenix's default port EXPOSE 4000 - diff --git a/README.md b/README.md index 94552ab..7579d0e 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,13 @@ This project uses Docker and Docker compose for development. To build the images docker-compose build ``` +??? -> "mix deps.get" + The first time you will need to create the DB: ``` docker-compose run web mix ecto.create +docker-compose run web mix ecto.migrate ``` Then, to start the app: diff --git a/priv/repo/migrations/20180330055909_add_updates_table.exs b/priv/repo/migrations/20180330055909_add_updates_table.exs index 7fe3e07..471fc26 100644 --- a/priv/repo/migrations/20180330055909_add_updates_table.exs +++ b/priv/repo/migrations/20180330055909_add_updates_table.exs @@ -8,8 +8,7 @@ defmodule WeatherStationManager.Repo.Migrations.AddUpdatesTable do add :lon, :float add :temperature, :float - timestamps + timestamps() end end end - diff --git a/web/stages/updates_db_consumer.ex b/web/stages/updates_db_consumer.ex index 972ac77..10a67b5 100644 --- a/web/stages/updates_db_consumer.ex +++ b/web/stages/updates_db_consumer.ex @@ -3,6 +3,8 @@ defmodule UpdatesDBConsumer do require Logger + alias WeatherStationManager.UpdatesRepository + def start_link() do GenStage.start_link(__MODULE__, :ok) end @@ -13,7 +15,7 @@ defmodule UpdatesDBConsumer do def handle_events(events, _from, state) do Logger.debug "[STAGE] - Write to DB: START" - Enum.each events, fn(_spam) -> Logger.debug "processing SQL..." end + Enum.each events, fn(event) -> UpdatesRepository.save event end Logger.debug "[STAGE] - Write to DB: DONE" { :noreply, [], state }