Here are the steps to update Phoenix Live SaaS Kit for Fly and Phoenix 1.6.9:
git init,git add .,git commit -m "init repo"- Remove generated docker & deploy script files
build.shdocker-entrypoint.sh.dockerignoreDockerfiledocker-compose.yml
- Update .tool-versions:
elixir 1.13.4-otp-24
erlang 24.3.4
- Open
mix.exsand update phoenix to1.6.9& phoenix_html to3.2.0 - Run
mix deps.get - Run
cd assetsthenrm yarn.lock. Will usenpmto match Dockerfile. - Run
npm install - Update runtime.exs database config:
maybe_ipv6 = if System.get_env("ECTO_IPV6"), do: [:inet6], else: []
config :demo, Demo.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
socket_options: maybe_ipv6
See: https://community.fly.io/t/how-to-run-ecto-create-for-an-elixir-app/5001/2
- Update runtime.ex endpoint config.
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")
config :demo, DemoWeb.Endpoint,
url: [host: host, port: 443, scheme: "https"],
http: [
# Enable IPv6 and bind on all interfaces.
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
# See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
secret_key_base: secret_key_base
Source: [error] Could not check origin for Phoenix.Socket transport. Origin of the request: https://live-saas-kit-demo.fly.dev. This happens when you are attempting a socket connection to a different host than the one configured in your config/ files.
- Run
fly launch, but do NOT deploy app because we need to update the Dockerfile - Add
nodejs && npmand addRUN cd assets && npm installto Dockerfile
Steps 1 & 3 from:
https://community.fly.io/t/elixir-getting-started-guide/1356/59
NOTE: Step 2 is already complete in the generated Dockerfile.
- Run
fly deploy --remote-onlyto finish deployment
Additional setup steps from Fullstack Phoenix
- Add Guardian secrets using
mix guardian.gen.secret
$ fly secrets set GUARDIAN_SECRET_KEY=secret GUARDIAN_SECRET_KEY_ADMINS=secret
- Create an admin using instructions from Fullstack Phoenix Admin Area.
- Delete
.github/wokflows/ci.yml - Create new repo on GitHub
- Generate Fly API token with
fly auth token - Store value as
FLY_API_TOKENin GitHub repository secrets - Add
.github/workflows/main.ymlfrom hello_fly project. - Merge changes and push to GitHub
- Sign up for a Mailgun account
- Add hackney package to
mix.exsand configure the Mailgun adapter (can uncommentruntime.configfile).
config :demo, Demo.Mailer,
adapter: Swoosh.Adapters.Mailgun,
api_key: System.get_env("MAILGUN_API_KEY"),
domain: System.get_env("MAILGUN_DOMAIN")
config :swoosh, :api_client, Swoosh.ApiClient.Hackney
- Set API Key and Domain as secrets in Fly
fly secrets set MAILGUN_API_KEY=my-api-key MAILGUN_DOMAIN=example.com
- Add authorized recipients (Mailgun sandbox mode only)
- Update
config.exswithfrom_email. Also update other company info...