Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Adding configuration to deploy to fly.io and upgrading to Phoenix 1.7 #111

Merged
merged 14 commits into from
Mar 16, 2023

Conversation

LuchoTurtle
Copy link
Member

@LuchoTurtle LuchoTurtle commented Feb 20, 2023

related to #86

This PR should address the needed config to deploy to fly.io.

It's still not working (check #86 as to why this is and why it's still in draft mode) but it deals with a few hurdles already.

  • Check readme

@LuchoTurtle LuchoTurtle added in-progress An issue or pull request that is being worked on by the assigned person chore a tedious but necessary task often paying technical debt labels Feb 20, 2023
@LuchoTurtle LuchoTurtle temporarily deployed to liveview-chat-example February 20, 2023 15:41 — with GitHub Actions Inactive
@LuchoTurtle
Copy link
Member Author

Getting error.message="instance refused connection" when trying to deploy and connect to it.

https://community.fly.io/t/instance-refused-connection/9961

Re-building doesn't seem to be working :/

@LuchoTurtle
Copy link
Member Author

The Dockerfile from https://github.com/dwyl/phoenix-chat-example/blob/main/Dockerfile seems to be similar to this one, so it should work, in theyro.

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

@LuchoTurtle do you want to pair on getting this done?

@LuchoTurtle
Copy link
Member Author

Sure

@LuchoTurtle
Copy link
Member Author

2023-03-01T09:34:02Z   [info]Starting init (commit: 08b4c2b)...
2023-03-01T09:34:02Z   [info]Preparing to run: `/app/bin/server` as nobody
2023-03-01T09:34:02Z   [info]2023/03/01 09:34:02 listening on [fdaa:1:66ce:a7b:2809:f56c:9c1e:2]:22 (DNS: [fdaa::3]:53)
--> v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1 

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

Keep getting this error, even after changing config.ex and runtime.ex with normal parameters (not pointing to Heroku).

@LuchoTurtle LuchoTurtle self-assigned this Mar 1, 2023
@LuchoTurtle LuchoTurtle had a problem deploying to liveview-chat-example March 1, 2023 09:47 — with GitHub Actions Failure
@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Ok. Let's speed-run this now. 🐎

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Sending build context to Docker daemon  59.19kB
[+] Building 76.1s (6/27)                                                                                                             
 => [internal] load remote build context                                                                                         0.0s
 => copy /context /                                                                                                              0.1s
 => [internal] load metadata for docker.io/hexpm/elixir:1.14.1-erlang-25.1.1-debian-bullseye-20220801-slim                       1.0s
 => [internal] load metadata for docker.io/library/debian:bullseye-20220801-slim                                                 0.9s
 => ERROR [builder  1/17] FROM docker.io/hexpm/elixir:1.14.1-erlang-25.1.1-debian-bullseye-20220801-slim@sha256:03ba790fed12ff  75.1s
 => => resolve docker.io/hexpm/elixir:1.14.1-erlang-25.1.1-debian-bullseye-20220801-slim@sha256:03ba790fed12ff8e4ec4243b66d5480  0.0s
 => => sha256:41368024d1e2ff41784e06ac4d2627fcae0f4f63669ff1084f2a3afc1ade87e7 5.25MB / 5.25MB                                   0.1s
 => => sha256:03ba790fed12ff8e4ec4243b66d54802ecc5ae81eec38acfcde4d21feea1193d 772B / 772B                                       0.0s
 => => sha256:9de014a78a1c23d957c839a85bf17a3ccafaa45ddbaf33ed09d04339394faae0 1.16kB / 1.16kB                                   0.0s
 => => sha256:9cbc096d345689a64313e042e3f8908efac1e2e374431dccc58ba20d9be39952 2.33kB / 2.33kB                                   0.0s
 => => sha256:58d3810f0cbf21328583a4f00b8f525f533e4366e5959211360916399b60bc0d 14.37MB / 14.37MB                                 0.2s
 => => sha256:c082ec3e945013d5e2e48a39e62140703ae0d82b4bf59cc2a263b5e169ba56b9 44.56MB / 44.56MB                                 0.4s
 => ERROR [stage-1 1/6] FROM docker.io/library/debian:bullseye-20220801-slim@sha256:a811e62769a642241b168ac34f615fb02da863307a  75.1s
 => => resolve docker.io/library/debian:bullseye-20220801-slim@sha256:a811e62769a642241b168ac34f615fb02da863307a14c4432cea8e5a0  0.0s
 => => sha256:a811e62769a642241b168ac34f615fb02da863307a14c4432cea8e5a0f9782b8 1.85kB / 1.85kB                                   0.0s
 => => sha256:139a42fa3bde3e5bad6ae912aaaf2103565558a7a73afe6ce6ceed6e46a6e519 529B / 529B                                       0.0s
 => => sha256:6a8065e4ba130e5f581c9fb79da4f58bc6513fa65fae1aba12418be4c5a7ed76 1.46kB / 1.46kB                                   0.0s
------
 > [builder  1/17] FROM docker.io/hexpm/elixir:1.14.1-erlang-25.1.1-debian-bullseye-20220801-slim@sha256:03ba790fed12ff8e4ec4243b66d54802ecc5ae81eec38acfcde4d21feea1193d:
------
------
 > [stage-1 1/6] FROM docker.io/library/debian:bullseye-20220801-slim@sha256:a811e62769a642241b168ac34f615fb02da863307a14c4432cea8e5a0f9782b8:
------
Error failed to fetch an image or build from source: error building: failed commit on ref "layer-sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7": "layer-sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7" failed size validation: 0 != 31366757: failed precondition

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Progress but not yet deployed:

image

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Eventually we get the following: ⏳

Failure #1

Instance
ID      	PROCESS	VERSION	REGION	DESIRED	STATUS 	HEALTH CHECKS      	RESTARTS	CREATED   
3f7a031b	app    	0      	mad   	run    	running	1 total, 1 critical	0       	4m48s ago	

Recent Events
TIMESTAMP           	TYPE      	MESSAGE                 
2023-03-01T10:14:44Z	Received  	Task received by client	
2023-03-01T10:14:44Z	Task Setup	Building Task Directory	
2023-03-01T10:14:48Z	Started   	Task started by client 	

2023-03-01T10:14:47Z   [info]Configuring firecracker
2023-03-01T10:14:47Z   [info]Starting virtual machine
2023-03-01T10:14:48Z   [info]Starting init (commit: 08b4c2b)...
2023-03-01T10:14:48Z   [info]Preparing to run: `/app/bin/server` as nobody
2023-03-01T10:14:48Z   [info]2023/03/01 10:14:48 listening on [fdaa:1:811c:a7b:e0:3f7a:31b:2]:22 (DNS: [fdaa::3]:53)
2023-03-01T10:19:32Z   [error]instance refused connection
2023-03-01T10:19:36Z   [warn]Could not proxy HTTP request. Retrying in 1000 ms (attempt 10)
2023-03-01T10:19:42Z   [error]instance refused connection
--> v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1 

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

@SimonLab suggested running flyctl version update to ensure flyctl is up-to-date ... ⌛ (running now ...)

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Now exporting the AUTH_API_KEY env var:

flyctl secrets set AUTH_API_KEY=88SwQFHmoyKLLddGN7NBrD2gq4qy7yCmKob8xLwLpYu/88SwQDEuH2wzHbS6aLAtHyPeLJZSvSCazgLHXkjse66PAsazE/authdemo.fly.dev

Output:

Release v1 created
==> Monitoring deployment
Logs: https://fly.io/apps/liveview-chat-example/monitoring

 1 desired, 1 placed, 0 healthy, 0 unhealthy

Let's see if that does anything for the deploy ... ⌛

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Still failing:

Failure #1

Instance
ID      	PROCESS	VERSION	REGION	DESIRED	STATUS 	HEALTH CHECKS      	RESTARTS	CREATED  
1f47ad52	app    	1      	mad   	run    	running	1 total, 1 critical	0       	5m6s ago	

Recent Events
TIMESTAMP           	TYPE      	MESSAGE                 
2023-03-01T10:23:36Z	Received  	Task received by client	
2023-03-01T10:23:54Z	Task Setup	Building Task Directory	
2023-03-01T10:23:58Z	Started   	Task started by client 	

2023-03-01T10:23:57Z   [info]Unpacking image
2023-03-01T10:23:57Z   [info]Preparing kernel init
2023-03-01T10:23:58Z   [info]Configuring firecracker
2023-03-01T10:23:58Z   [info]Starting virtual machine
2023-03-01T10:23:58Z   [info]Starting init (commit: 08b4c2b)...
2023-03-01T10:23:58Z   [info]Preparing to run: `/app/bin/server` as nobody
2023-03-01T10:23:58Z   [info]2023/03/01 10:23:58 listening on [fdaa:1:811c:a7b:e0:1f47:ad52:2]:22 (DNS: [fdaa::3]:53)
--> v1 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v2 

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

@LuchoTurtle
Copy link
Member Author

Check this: https://fly.io/docs/getting-started/troubleshooting/#host-checking

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Yeah, that appears to resolve the issue for a Node.js App ... 🔍
Think we need to find config specific to Phoenix to make sure we get this working. 💭

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

If you are running checks. please comment. 🙏

@LuchoTurtle
Copy link
Member Author

Everything under config folder matches with https://github.com/dwyl/phoenix-chat-example

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

Ok. I think we can park this for now ... 🅿️
This might just be a Fly.io stability issue that will resolve itself ... ⏳

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

I've deleted the fly app that was deployed to the MAD (Madrid) region. 🇪🇸
Re-deploying to LON (London) 🇬🇧

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

==> Creating release
--> release v2 created

--> You can detach the terminal anytime without stopping the deployment
==> Release command detected: /app/bin/migrate

--> This release will not be available until the release command succeeds.
	 Starting instance
	 Configuring virtual machine
	 Pulling container image
	 Unpacking image
	 Preparing kernel init
	 Configuring firecracker
	 Starting virtual machine
	 Starting init (commit: 08b4c2b)...
	 Preparing to run: `/app/bin/migrate` as nobody
	 2023/03/01 11:17:27 listening on [fdaa:1:811c:a7b:bada:87c6:54b6:2]:22 (DNS: [fdaa::3]:53)
	 11:17:30.023 [info] == Running 20211122121548 LiveviewChat.Repo.Migrations.CreateMessages.change/0 forward
	 11:17:30.028 [info] create table messages
	 11:17:30.048 [info] == Migrated 20211122121548 in 0.0s
	 Starting clean up.
	 Starting instance
	 Configuring virtual machine
	 Pulling container image
	 Unpacking image
	 Preparing kernel init
	 Configuring firecracker
	 Starting virtual machine
	 Starting init (commit: 08b4c2b)...
	 Preparing to run: `/app/bin/migrate` as nobody
	 2023/03/01 11:17:27 listening on [fdaa:1:811c:a7b:bada:87c6:54b6:2]:22 (DNS: [fdaa::3]:53)
	 11:17:30.023 [info] == Running 20211122121548 LiveviewChat.Repo.Migrations.CreateMessages.change/0 forward
	 11:17:30.028 [info] create table messages
	 11:17:30.048 [info] == Migrated 20211122121548 in 0.0s
	 Starting clean up.
	 Starting instance
	 Configuring virtual machine
	 Pulling container image
	 Unpacking image
	 Preparing kernel init
	 Configuring firecracker
	 Starting virtual machine
	 Starting init (commit: 08b4c2b)...
	 Preparing to run: `/app/bin/migrate` as nobody
	 2023/03/01 11:17:27 listening on [fdaa:1:811c:a7b:bada:87c6:54b6:2]:22 (DNS: [fdaa::3]:53)
	 11:17:30.023 [info] == Running 20211122121548 LiveviewChat.Repo.Migrations.CreateMessages.change/0 forward
	 11:17:30.028 [info] create table messages
	 11:17:30.048 [info] == Migrated 20211122121548 in 0.0s
	 Starting clean up.
==> Monitoring deployment
Logs: https://fly.io/apps/liveview-chat-example/monitoring

 1 desired, 1 placed, 0 healthy, 0 unhealthy [health checks: 1 total, 1 critical]

Still "critical" ... 🤷

@nelsonic
Copy link
Member

nelsonic commented Mar 1, 2023

OK. honestly this has sucked enough of our time now. (Almost T2h of my time and even more of yours ...!) ⏳ 💸 🔥
Let's park it and come back to it at another time. 🅿️
We can post a question on the Fly.io forum and see if someone @fly can help ... 💭

@SimonLab SimonLab force-pushed the deploy-to-fly_#86 branch from 4fd65cf to 98e57ad Compare March 15, 2023 10:50
@SimonLab SimonLab temporarily deployed to liveview-chat-example March 15, 2023 10:50 — with GitHub Actions Inactive
- Check dependencies with `mix hex.outdated`
- Update the available dependencies with `mix deps.update --all`
- Clean the lock file to remove unsued dependencies with
`mix deps.clean --unlock --unused`
@SimonLab SimonLab temporarily deployed to liveview-chat-example March 15, 2023 10:59 — with GitHub Actions Inactive
@SimonLab
Copy link
Member

Running mix setup compile the project, just a few warnings we can try to resolve later on:
image

@SimonLab
Copy link
Member

I've updated the dependencies and tried to deploy the application, however the error is still the same.
I've checked the status of the application and restarted the vm. I've also recreated the fly.tom. and Dockerfile and attempted to launch the application. I'm starting the think the error might be linked to fly.io instead of our configuration but I might be wrong and missing something. I've created the following post on the fly.io community: https://community.fly.io/t/cant-deploy-launch-application-health-check-on-port-8080-has-failed/11471

Dockerfile Outdated
ENV ECTO_IPV6 true
ENV ERL_AFLAGS "-proto_dist inet6_tcp"

# Appended by flyctl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete these lines, you only need it once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for checking the Dockerfile, I've pushed the latest versions of the Dockerfile and fly.toml

Dockerfile Outdated
ENV ECTO_IPV6 true
ENV ERL_AFLAGS "-proto_dist inet6_tcp"

# Appended by flyctl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this extra lines

Attempt to recreate the fly.toml and Dockerfile after updating flyctl
@SimonLab SimonLab temporarily deployed to liveview-chat-example March 15, 2023 14:50 — with GitHub Actions Inactive
config/runtime.exs Outdated Show resolved Hide resolved
Co-authored-by: Jason S. <stiebs.81@gmail.com>
@nelsonic nelsonic temporarily deployed to liveview-chat-example March 15, 2023 16:46 — with GitHub Actions Inactive
@SimonLab SimonLab removed their assignment Mar 15, 2023
Copy link
Member

@SimonLab SimonLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The application is now deployed on Fly (we still need to add manually the auth environment variable)

Copy link
Member

@nelsonic nelsonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👌
Thanks @LuchoTurtle, @jeregrine & @SimonLab 🙌

@nelsonic nelsonic merged commit c1a2181 into main Mar 16, 2023
@nelsonic nelsonic deleted the deploy-to-fly_#86 branch March 16, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a tedious but necessary task often paying technical debt external-dependency Depends on an entity/dependency external to the team's control in-progress An issue or pull request that is being worked on by the assigned person
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants