--- /dev/null
+FROM elixir:1.17.3
+
+ENV MIX_ENV=prod
+ENV APP_VERSION="0.1.0"
+
+RUN mix local.hex --force && \
+ mix local.rebar --force && \
+ mkdir /build
+
+WORKDIR /build
+COPY ./mix.exs /build
+COPY ./mix.lock /build
+COPY ./config/runtime.exs /build/config/runtime.exs
+RUN mix do deps.get, deps.compile
+
+COPY . /build
+RUN mix release
+
+ENV PORT=53
+ENV PGHOST PGUSER PGPASSWORD PGDATABASE
+
+WORKDIR /app
+
+CMD /build/_build/prod/rel/dns_phrases/bin/dns_phrases start
--- /dev/null
+import Config
+
+config :dns_phrasex,
+ port:
+ (case System.fetch_env!("PORT") |> Integer.parse() do
+ {port, _} -> port
+ :error -> 53
+ end)
services:
+ app:
+ image: aloussase69/dns-phrasex
+ restart: unless-stopped
+ build:
+ context: .
+ ports:
+ - "5353:53/udp"
+ environment:
+ PGHOST: db
+ PGDATABASE: postgres
+ PGUSER: postgres
+ PGPASSWORD: postgres
+ depends_on:
+ - db
+
db:
image: postgres:17
restart: unless-stopped
@impl true
def start(_type, _args) do
- opts = [port: :integer]
- {parsed, _, _} = OptionParser.parse(System.argv(), strict: opts)
+ port = Application.fetch_env!(:dns_phrasex, :port)
children = [
{Postgrex, [name: :db]},
- {DnsPhrases.Server, [listen_port: parsed[:port]]}
+ {DnsPhrases.Server, [listen_port: port]}
]
opts = [strategy: :one_for_one, name: DnsPhrases.Supervisor]