Skip to content

Commit

Permalink
Fix fly deployment
Browse files Browse the repository at this point in the history
Normalize config with other projects.
  • Loading branch information
ringvold committed Dec 19, 2024
1 parent d7ac5a1 commit 182b890
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 104 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG ELIXIR_VERSION=1.17.2
ARG OTP_VERSION=27.0.1
ARG DEBIAN_VERSION=bookworm-20240701-slim
ARG ELIXIR_VERSION=1.18.0
ARG OTP_VERSION=27.2
ARG DEBIAN_VERSION=bookworm-20241202-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
Expand Down
49 changes: 9 additions & 40 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ if System.get_env("GET5API_IP") do
end
end

if System.get_env("PHX_SERVER") do
config :get5_api, Get5ApiWeb.Endpoint, server: true
end

if config_env() == :prod do
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
Expand All @@ -38,17 +42,14 @@ if config_env() == :prod do
You can generate one by calling: mix phx.gen.secret
"""

app_name =
System.get_env("FLY_APP_NAME") ||
raise "FLY_APP_NAME not available"
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")

config :get5_api, Get5ApiWeb.Endpoint,
server: true,
url: [host: "#{app_name}.fly.dev", port: 80],
url: [host: host, port: 443, scheme: "https"],
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
# IMPORTANT: support IPv6 addresses
transport_options: [socket_opts: [:inet6]]
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
secret_key_base: secret_key_base

Expand All @@ -68,35 +69,3 @@ if config_env() == :prod do
socket_options: [:inet6],
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
end

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to your endpoint configuration:
#
# config :my_app, MyAppWeb.Endpoint,
# https: [
# ...,
# port: 443,
# cipher_suite: :strong,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")
# ]
#
# The `cipher_suite` is set to `:strong` to support only the
# latest and more secure SSL ciphers. This means old browsers
# and clients may not be supported. You can set it to
# `:compatible` for wider support.
#
# `:keyfile` and `:certfile` expect an absolute path to the key
# and cert in disk or a relative path inside priv, for example
# "priv/ssl/server.key". For all supported SSL configuration
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
#
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :my_app, MyAppWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
45 changes: 16 additions & 29 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
# fly.toml file generated for get5-api on 2021-09-01T00:02:30+02:00

app = "get5-api"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []
primary_region = 'ams'
kill_signal = 'SIGTERM'

[env]
PHX_HOST = 'get5-api.fly.dev'
PORT = '8080'

[deploy]
release_command = '/app/bin/migrate'

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]
internal_port = 4000
protocol = "tcp"

[services.concurrency]
hard_limit = 25
soft_limit = 20

[[services.ports]]
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "30s" # allow some time for startup
interval = "15s"
restart_limit = 6
timeout = "2s"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
processes = ['app']

[http_service.concurrency]
type = 'connections'
hard_limit = 1000
soft_limit = 1000
6 changes: 0 additions & 6 deletions rel/env.bat.eex

This file was deleted.

10 changes: 6 additions & 4 deletions rel/env.sh.eex
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/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"
# configure node for distributed erlang with IPV6 support
export ERL_AFLAGS="-proto_dist inet6_tcp"
export ECTO_IPV6="true"
export DNS_CLUSTER_QUERY="${FLY_APP_NAME}.internal"
export RELEASE_DISTRIBUTION="name"
export RELEASE_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}"
11 changes: 0 additions & 11 deletions rel/remote.vm.args.eex

This file was deleted.

11 changes: 0 additions & 11 deletions rel/vm.args.eex

This file was deleted.

0 comments on commit 182b890

Please sign in to comment.