fklement
Problems with deploying phoenix application to Elastic Beanstalk
I’ve some problems deploying my existing application to aws’s elastic beanstalk.
I’m struggling with the environment variables because I’m receiving the following error from the logs:
-------------------------------------
/var/log/eb-docker/containers/eb-current-app/unexpected-quit.log
-------------------------------------
(db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
11:05:31.352 [error] GenServer #PID<0.477.0> terminating
** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
(elixir) lib/keyword.ex:393: Keyword.fetch!/2
(postgrex) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
(db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
My prod.exs looks like this:
use Mix.Config
config :supercoolapplication, SuperCoolApplicationWeb.Endpoint,
http: [port: {:system, "PORT"}, compress: true],
url: [scheme: "http", host: System.get_env("HOST"), port: {:system, "PORT"}],
secret_key_base: System.get_env("SECRET_KEY_BASE"),
code_reloader: false,
cache_static_manifest: "priv/static/cache_manifest.json",
server: true
# Do not print debug messages in production
config :logger, level: :info
config :phoenix_crud, PhoenixCrud.Repo,
adapter: Ecto.Adapters.Postgres,
database: System.get_env("RDS_DB_NAME"),
username: System.get_env("RDS_USERNAME"),
password: System.get_env("RDS_PASSWORD"),
hostname: System.get_env("RDS_HOSTNAME"),
port: System.get_env("RDS_PORT") || 5432,
pool_size: 20,
ssl: true
I basically followed this tutorial on thoughtbot.
My Dockerfile looks like this:
FROM bitwalker/alpine-elixir-phoenix:latest
# Set exposed ports
EXPOSE 4000
ENV PORT=4000 MIX_ENV=dev
# Cache elixir deps
ADD mix.exs mix.lock ./
RUN mix do deps.get, deps.compile
# Same with npm deps
ADD assets/package.json assets/
RUN cd assets && \
npm install
ADD . .
# Run frontend build, compile, and digest assets
RUN cd assets/ && \
npm run deploy && \
cd - && \
mix do compile, phx.digest
USER default
CMD ["mix", "phx.server"]
I created my elastic beanstalk environment like the following:
eb create \
--database \
-db.engine postgres \
-db.i db.t2.small \
-db.size 10 \
-db.version 9.4.5 \
--envvars MIX_ENV=prod,SECRET_KEY_BASE=heregoesmyprettysecurekey,PORT=4000
Has anyone an idea what is going wrong on my side?
And I’m also questioning myself on how I should actually run the mix ecto.create task and then after every deployment the mix ecto.migrate task…
I would be happy about any help!!!
First Post!
Moxide
Hello,
I think you need to pass all the env vars you are using in your configuration (RDS_DB_NAME, …etc.) through the --envvars option.
Popular in Questions
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lists...
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone.
What strikes me is th...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Other popular topics
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Got a question about when to concat vs. prepending items to list then reversing to achieve appending.
So i know lists boil down to [1 | ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








