]> git.frustrated-labs.net Git - dns-phrasex.git/commitdiff
feat: configure docker deployment
authorAlexander Goussas <[email protected]>
Tue, 3 Feb 2026 02:38:33 +0000 (21:38 -0500)
committerAlexander Goussas <[email protected]>
Tue, 3 Feb 2026 02:38:33 +0000 (21:38 -0500)
Dockerfile [new file with mode: 0644]
config/runtime.exs [new file with mode: 0644]
docker-compose.yml
lib/dns_phrases/application.ex

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..eb7f2ae
--- /dev/null
@@ -0,0 +1,24 @@
+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
diff --git a/config/runtime.exs b/config/runtime.exs
new file mode 100644 (file)
index 0000000..76f71ca
--- /dev/null
@@ -0,0 +1,8 @@
+import Config
+
+config :dns_phrasex,
+  port:
+    (case System.fetch_env!("PORT") |> Integer.parse() do
+       {port, _} -> port
+       :error -> 53
+     end)
index 31770c585210986e4b3c974e794973181f676af1..1102eab42275c4b4b89daeb3f0cb07c1036e3191 100644 (file)
@@ -1,4 +1,19 @@
 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
index 5b0c4ee32abd70bcef262212e0aed6d1e9b24943..98293c6fb91076bdc186f4446e40d80c5121a253 100644 (file)
@@ -7,12 +7,11 @@ defmodule DnsPhrases.Application do
 
   @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]