dwyl / learn-elixir

:droplet: Learn the Elixir programming language to build functional, fast, scalable and maintainable web applications!
1.6k stars 107 forks source link

Trying to deploy on Gigalixir #176

Open mingyar opened 1 year ago

mingyar commented 1 year ago

Hey guys! How things are going over there? πŸ˜ƒ

First, thank you for having me at dwl! 🀠

Second, I'm not sure if this is the right place for this kind of question, but here we go:

I using Elixir releases and when I hit: git push gigalixir I got:

-----> Fetching app dependencies with mix
remote: ** (File.Error) could not read file β€œ/tmp/build/config/prod.secret.exs”: no such file or directory
remote:     (elixir 1.11.3) lib/file.ex:355: File.read!/1
remote:     (elixir 1.11.3) lib/config.ex:240: Config.__import__!/1
remote:     (mix 1.11.3) lib/mix/config.ex:161: anonymous fn/2 in Mix.Config.__import__!/2
remote:     (elixir 1.11.3) lib/enum.ex:2193: Enum.β€œ-reduce/3-lists^foldl/2-0-β€œ/3
remote:     (mix 1.11.3) lib/mix/config.ex:160: Mix.Config.__import__!/2
remote:     (stdlib 3.14) erl_eval.erl:680: :erl_eval.do_apply/6
remote: 2022/08/31 03:29:55 exit status 1
remote: Deploy aborted

Am I missing something?

nelsonic commented 1 year ago

Hey @mingyar πŸ‘‹ you're up early (late?) for Brazil. πŸ‡§πŸ‡· β˜€οΈ πŸ’­ All questions are welcome. πŸ‘Œ

You appear to be using a prod.secret.exs file for your secrets. Do you need it? If not, simply comment out the line in your prod.exs file e.g: https://github.com/dwyl/auth/blob/f6a72102fd72f99ba8c42d00083e22c2fdec917a/config/prod.exs#L55

That should deploy fine. If not, share the next error message you see and we will attempt to help you debug. πŸ¦†

mingyar commented 1 year ago

Hi @nelsonic πŸ‘‹πŸ» Yup, I was up a bite late (around 3 a.m. here in Brazil), trying to make this deploy work πŸ˜†

Yes! That was my guess, I think I don't need it since I have a releases.exs that looks like this:

import Config

config :rockelivery, RockeliveryWeb.Endpoint,
  server: true,
  http: [port: {:system, "PORT"}],
  url: [host: System.get_env("APP_NAME") <> ".gigalixirapp.com", port: 443]

I'll try to comment that and let's see what happens!

Thank you for helping @nelsonic!

mingyar commented 1 year ago

Apparently the deploy has been made, but my app status keeps unhealthy: image Then I'm tried to run the release locally, so I did: SECRET_KEY_BASE="$(mix phx.gen.secret)" MIX_ENV=prod DATABASE_URL="postgresql://postgres:postgres@localhost:5432/rockelivery" PORT=4000 mix phx.server and now I’m getting:

** (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 1.12.2) lib/keyword.ex:420: Keyword.fetch!/2
    (postgrex 0.16.3) lib/postgrex/protocol.ex:160: Postgrex.Protocol.connect_endpoints/6
    (db_connection 2.4.2) lib/db_connection/connection.ex:82: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3 

Which explain why the app status is unhealthy.

Any ideas on why this is happening?

nelsonic commented 1 year ago

Hmm that’s strange. How is :database required in your config prod.exs file?

mingyar commented 1 year ago

I find out what was happening!

I was following instructions during this course that I'm doing.

So I had prod.secret.exs on my .gitignore file 🀑 (because we supposed should)

Aaaand, yes, you can imagine what comes next: I checked the .gitignore from the instructors repository, and guess what?

He doesn't had prod.secret.exs on his .gitignore πŸ€¦πŸ»β€β™‚οΈ πŸ€¦πŸ»β€β™‚οΈ πŸ€¦πŸ»β€β™‚οΈ

That's why the all thing was working for him end not for me πŸ¦†

nelsonic commented 1 year ago

good detective work. πŸ‘Œ Glad you figured it out. πŸš€

nelsonic commented 1 year ago

what "course" are you following? πŸ’­

mingyar commented 1 year ago

I just finished the Elixir trail from Ignite.

Ignite is a program from Rocketseat, looks pretty much like pluralsight or codeschool.