From 874252709b70d24bbd48072a0d1cf0f10a5f2fc4 Mon Sep 17 00:00:00 2001 From: Anze Skulj <anze.skulj@comsensus.eu> Date: Wed, 29 Jan 2025 11:13:02 +0100 Subject: [PATCH 1/2] dockerfile fixes --- Dockerfile | 11 +++++++++-- config/runtime.exs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd6aadb..ce40468 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,8 +33,6 @@ RUN mix local.hex --force && \ # set build ENV ENV MIX_ENV="prod" -ENV DATABASE_URL = "ecto://USER:PASS@HOST/DATABASE" -ENV SECRET_KEY_BASE = zYRQiZHSoacOEgsM9w0dW4YgMQeIOrHjlM63tkAdlTlHG6lXiCrkls2TD6khDliA # install mix dependencies COPY mix.exs mix.lock ./ @@ -86,11 +84,20 @@ RUN chown nobody /app # set runner ENV ENV MIX_ENV="prod" +#ENV DATABASE_URL="ecto://USER:PASS@HOST/DATABASE" +#ENV SECRET_KEY_BASE=zYRQiZHSoacOEgsM9w0dW4YgMQeIOrHjlM63tkAdlTlHG6lXiCrkls2TD6khDliA +#ENV PHX_SERVER=true +#ENV PHX_HOST="localhost" +#ENV PORT=4000 + # Only copy the final release from the build stage COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/nemo_cloud_services ./ USER nobody +EXPOSE 4000 + + # If using an environment that doesn't automatically reap zombie processes, it is # advised to add an init process such as tini via `apt-get install` # above and adding an entrypoint. See https://github.com/krallin/tini for details diff --git a/config/runtime.exs b/config/runtime.exs index ff92333..a530cd1 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -60,7 +60,7 @@ if config_env() == :prod do # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access. # See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0 # for details about using IPv6 vs IPv4 and loopback vs public addresses. - ip: {0, 0, 0, 0, 0, 0, 0, 0}, + ip: {0, 0, 0, 0}, port: port ], secret_key_base: secret_key_base -- GitLab From 999a7732aef682d2ea512a606f89f492c2f42da7 Mon Sep 17 00:00:00 2001 From: Anze <anze.skulj@comsensus.eu> Date: Wed, 29 Jan 2025 13:13:57 +0100 Subject: [PATCH 2/2] docker fixes --- config/runtime.exs | 6 ++++-- docker-compose.yml | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yml diff --git a/config/runtime.exs b/config/runtime.exs index a530cd1..611c0d2 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -61,9 +61,11 @@ if config_env() == :prod do # See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0 # for details about using IPv6 vs IPv4 and loopback vs public addresses. ip: {0, 0, 0, 0}, - port: port + port: port, ], - secret_key_base: secret_key_base + secret_key_base: secret_key_base, + server: true, + check_origin: false # ## SSL Support # diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..49956bb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.8' + +services: + nemo_cloud_service: + build: . + container_name: "nemo_cloud_service_app" + + # Publish port 4000 directly to your host + ports: + - "4000:4000" + + environment: + - PHX_SERVER=true + - PORT=4000 + - MIX_ENV=prod + - DATABASE_URL= "ecto://user:pass@localhost/krendb" + - SECRET_KEY_BASE=zYRQiZHSoacOEgsM9w0dW4YgMQeIOrHjlM63tkAdlTlHG6lXiCrkls2TD6khDliA + - PHX_HOST=0.0.0.0 + +networks: + default: + driver: bridge \ No newline at end of file -- GitLab