Hi,
I’m trying to deploy my phoenix api project using fly.io so I followed the instructions here using mix release.
When I try to deploy my app it says /app/bin/senti: /app/bin/senti: No such file or directory
. Is there anything wrong that I made?
➜ senti git:(main) ✗ fly deploy
Deploying winter-wildflower-8614
==> Validating app configuration
--> Validating app configuration done
Services
TCP 80/443 ⇢ 4000
==> Building image with Buildpacks
20: Pulling from heroku/buildpacks
Digest: sha256:e8b7f2e1976bd815dc018f6ea83bccdabcb24b17158781c930124af29cda33d6
Status: Image is up to date for heroku/buildpacks:20
20: Pulling from heroku/pack
Digest: sha256:7bb820682c2a756c91bec06c081403eb30a54afa013ab7a3ddc15b6e76cd0e40
Status: Image is up to date for heroku/pack:20
Downloading from https://cnb-shim.herokuapp.com/v1/hashnuke/elixir
1.88 MB/-1 B
===> DETECTING
hashnuke/elixir 0.1
===> ANALYZING
Previous image with name "registry.fly.io/winter-wildflower-8614:deployment-1621173527" not found
===> RESTORING
===> BUILDING
-----> Will export the following config vars:
* MIX_ENV=prod
-----> Checking Erlang and Elixir versions
Will use the following versions:
* Stack heroku-20
* Erlang 23.3.4
* Elixir v1.11.2
-----> Stack changed, will rebuild
-----> Fetching Erlang 23.3.4 from https://repo.hex.pm/builds/otp/ubuntu-20.04/OTP-23.3.4.tar.gz
-----> Installing Erlang 23.3.4 (changed)
-----> Fetching Elixir v1.11.2 for OTP 23 from https://repo.hex.pm/builds/elixir/v1.11.2-otp-23.zip
-----> Installing Elixir v1.11.2 (changed)
-----> Installing Hex
* creating /home/heroku/.mix/archives/hex-0.21.2
-----> Installing rebar
* creating /home/heroku/.mix/rebar
* creating /home/heroku/.mix/rebar3
-----> Fetching app dependencies with mix
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
argon2_elixir 2.4.0
comeonin 5.3.2
connection 1.1.0
cors_plug 2.0.3
cowboy 2.8.0
cowboy_telemetry 0.3.1
cowlib 2.9.1
db_connection 2.4.0
decimal 2.0.0
ecto 3.6.1
ecto_sql 3.6.1
elixir_make 0.6.2
gettext 0.18.2
jason 1.2.2
mime 1.6.0
nanoid 2.0.5
phoenix 1.5.8
phoenix_ecto 4.2.1
phoenix_html 2.14.3
phoenix_live_dashboard 0.4.0
phoenix_live_view 0.15.5
phoenix_pubsub 2.0.0
plug 1.11.1
plug_cowboy 2.5.0
plug_crypto 1.2.2
postgrex 0.15.9
ranch 1.7.1
telemetry 0.4.3
telemetry_metrics 0.6.0
telemetry_poller 0.5.1
All dependencies are up to date
-----> Copying hex from /home/heroku/.mix/archives/hex-0.21.2
-----> Compiling
==> connection
Compiling 1 file (.ex)
Generated connection app
==> gettext
Compiling 1 file (.erl)
Compiling 20 files (.ex)
Generated gettext app
===> Compiling ranch
===> Failed to restore /workspace/deps/ranch/.rebar3/rebar_compiler_erl/source.dag file. Discarding it.
===> Compiling telemetry
===> Failed to restore /workspace/deps/telemetry/.rebar3/rebar_compiler_erl/source.dag file. Discarding it.
==> telemetry_metrics
Compiling 7 files (.ex)
Generated telemetry_metrics app
===> Compiling telemetry_poller
===> Failed to restore /workspace/deps/telemetry_poller/.rebar3/rebar_compiler_erl/source.dag file. Discarding it.
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> jason
Compiling 8 files (.ex)
Generated jason app
==> comeonin
Compiling 4 files (.ex)
Generated comeonin app
==> elixir_make
Compiling 1 file (.ex)
Generated elixir_make app
==> argon2_elixir
mkdir -p /workspace/_build/prod/lib/argon2_elixir/priv
cc -g -O3 -pthread -Wall -Wno-format-truncation -I"/app/.platform_tools/erlang/erts-11.2.2/include" -Iargon2/include -Iargon2/src -Ic_src -shared -fPIC -fvisibility=hidden -Wl,-soname,libargon2.so.0 argon2/src/argon2.c argon2/src/core.c argon2/src/blake2/blake2b.c argon2/src/thread.c argon2/src/encoding.c argon2/src/ref.c c_src/argon2_nif.c -o /workspace/_build/prod/lib/argon2_elixir/priv/argon2_nif.so
Compiling 3 files (.ex)
Generated argon2_elixir app
==> db_connection
Compiling 14 files (.ex)
Generated db_connection app
==> ecto
Compiling 56 files (.ex)
Generated ecto app
==> phoenix_pubsub
Compiling 11 files (.ex)
Generated phoenix_pubsub app
===> Compiling cowlib
===> Failed to restore /workspace/deps/cowlib/.rebar3/rebar_compiler_erl/source.dag file. Discarding it.
===> Compiling cowboy
===> Failed to restore /workspace/deps/cowboy/.rebar3/rebar_compiler_erl/source.dag file. Discarding it.
===> Compiling cowboy_telemetry
===> Failed to restore /workspace/deps/cowboy_telemetry/.rebar3/rebar_compiler_erl/source.dag file. Discarding it.
==> nanoid
Compiling 4 files (.ex)
Generated nanoid app
==> mime
Compiling 2 files (.ex)
Generated mime app
==> postgrex
Compiling 61 files (.ex)
Generated postgrex app
==> ecto_sql
Compiling 26 files (.ex)
Generated ecto_sql app
==> plug_crypto
Compiling 5 files (.ex)
Generated plug_crypto app
==> plug
Compiling 1 file (.erl)
Compiling 41 files (.ex)
warning: System.stacktrace/0 is deprecated, use __STACKTRACE__ instead
lib/plug/conn/wrapper_error.ex:23
warning: MIME.valid?/1 is deprecated. Use MIME.extensions(type) != [] instead
lib/plug/mime.ex:32: Plug.MIME.valid?/1
Generated plug app
==> plug_cowboy
Compiling 5 files (.ex)
Generated plug_cowboy app
==> cors_plug
Compiling 1 file (.ex)
Generated cors_plug app
==> phoenix_html
Compiling 8 files (.ex)
Generated phoenix_html app
==> phoenix
Compiling 66 files (.ex)
Generated phoenix app
==> phoenix_live_view
Compiling 22 files (.ex)
Generated phoenix_live_view app
==> phoenix_live_dashboard
Compiling 36 files (.ex)
Generated phoenix_live_dashboard app
==> phoenix_ecto
Compiling 7 files (.ex)
Generated phoenix_ecto app
==> senti
Compiling 37 files (.ex)
Generated senti app
warning: the dependency pow is not present in the build directory
* Cleaning pow
-----> Creating .profile.d with env vars
-----> Writing export for multi-buildpack support
===> EXPORTING
Adding layer 'hashnuke/elixir:profile'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Saving registry.fly.io/winter-wildflower-8614:deployment-1621173527...
*** Images (36be27084d72):
registry.fly.io/winter-wildflower-8614:deployment-1621173527
Adding cache layer 'hashnuke/elixir:shim'
--> Building image done
==> Pushing image to fly
The push refers to repository [registry.fly.io/winter-wildflower-8614]
83d85471d9f8: Layer already exists
41c57834b79a: Layer already exists
20e1cf6014bd: Layer already exists
dca58f1aac35: Pushed
911870c321d2: Layer already exists
95668a62a6a6: Pushed
140533a8850e: Pushed
e9677c99d3a6: Pushed
4125fa93a795: Pushed
2f140462f3bc: Pushed
63c99163f472: Pushed
ccdbb80308cc: Pushed
deployment-1621173527: digest: sha256:73294bb250b7e5a5c2c45e5cb445e773e0fe72d9fda8119d92427e5dde0d5627 size: 2823
--> Pushing image done
Image: registry.fly.io/winter-wildflower-8614:deployment-1621173527
Image size: 2.1 GB
==> Creating release
Release v2 created
Release command detected: this new release will not be available until the command succeeds.
You can detach the terminal anytime without stopping the deployment
==> Release command
Command: /app/bin/senti eval Senti.Release.migrate
Starting instance
Configuring virtual machine
Pulling container image
Unpacking image
Preparing kernel init
Configuring firecracker
Starting virtual machine
Starting init (commit: cc4f071)...
Running: `launcher /app/bin/senti eval Senti.Release.migrate` as heroku
2021/05/16 14:04:40 listening on [fdaa:0:2a2a:a7b:aaa:73ad:8867:2]:22 (DNS: [fdaa::3]:53)
/app/bin/senti: /app/bin/senti: No such file or directory
Main child exited normally with code: 127
Starting clean up.
Error Release command failed, deployment aborted
➜ senti git:(main) ✗
Here’s what I’ve done:
Create file to run DB migration lib/senti/release.ex
defmodule Senti.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :senti
def migrate do
load_app()
for repo <- repos() do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end
defp repos do
Application.fetch_env!(@app, :ecto_repos)
end
defp load_app do
Application.load(@app)
end
end
Update `rel/env.sh.eex`` file
#!/bin/sh
ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=$FLY_APP_NAME@$ip
export ELIXIR_ERL_OPTIONS="-proto_dist inet6_tcp"
Create runtime config
import Config
if config_env() == :prod do
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""
app_name =
System.get_env("FLY_APP_NAME") ||
raise "FLY_APP_NAME not available"
config :senti, SentiWeb.Endpoint,
server: true,
url: [host: "#{app_name}.fly.dev", port: 80],
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
# IMPORTANT: support IPv6 addresses
transport_options: [socket_opts: [:inet6]]
],
secret_key_base: secret_key_base
database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE
"""
config :senti, Senti.Repo,
url: database_url,
# IMPORTANT: Or it won't find the DB server
socket_options: [:inet6],
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
end
Remove the last line of config/prod.exs that says import_config “prod.secret.exs”.
Create elixir_buildpack.config
erlang_version=23.3.4
elixir_version=1.11.2
My apologies if the thread is long I just need to layout all changes I’ve made so its easier to know what’s I did wrong.
Hope someone could point out the problem. Thank you very much.