Skip to content

Commit

Permalink
fix: set proper release node to reopen mnesia (#1197)
Browse files Browse the repository at this point in the history
* fix: set proper release node to reopen mnesia

* chore: replace Dockerfile.dev using mix runner (#1199)
  • Loading branch information
jyeshe authored Feb 23, 2023
1 parent 32e0836 commit a133ea4
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: ./.github/actions/tests-common

- name: Execute tests
run: docker-compose -f docker-compose-test.yml run --rm ae_mdw ./test.sh
run: docker-compose -f docker-compose-test.yml run --rm ae_mdw

test-coverage:
name: Test coverage
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# - Ex: hexpm/elixir:1.13.4-erlang-23.3.4.17-debian-bullseye-20210902-slim
#
ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=23.3.4.17
ARG OTP_VERSION=23.3.4.18
ARG DEBIAN_VERSION=bullseye-20220801-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
Expand Down Expand Up @@ -61,7 +61,8 @@ RUN mix local.hex --force && \
mix local.rebar --force

# set build ENV
ENV MIX_ENV="prod"
ARG MIX_ENV="prod"
ENV MIX_ENV=${MIX_ENV}

# install mix dependencies
COPY mix.exs mix.lock ./
Expand Down Expand Up @@ -93,7 +94,7 @@ RUN mix release
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}

RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales libncurses5 libsodium-dev libgmp10 \
RUN apt-get update -y && apt-get install -y git libstdc++6 openssl libncurses5 locales libncurses5 libsodium-dev libgmp10 \
&& ldconfig \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*

Expand All @@ -109,7 +110,8 @@ ENV NODEDIR=/home/aeternity/node/local/rel/aeternity
WORKDIR "/home/aeternity/node"

# set runner ENV
ENV MIX_ENV="prod"
ARG MIX_ENV="prod"
ENV MIX_ENV=${MIX_ENV}
ENV AETERNITY_CONFIG=/home/aeternity/aeternity.yaml

# Only copy the final release from the build stage
Expand All @@ -121,6 +123,7 @@ RUN mkdir -p ./local/rel/aeternity/data/mnesia

RUN chown -R nobody /home/aeternity/node

USER nobody
ARG USER=nobody
USER ${USER}

CMD ["/home/aeternity/node/bin/server"]
56 changes: 0 additions & 56 deletions Dockerfile.dev

This file was deleted.

13 changes: 0 additions & 13 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
import Config

# Stat
mdw_revision =
case File.read("AEMDW_REVISION") do
{:ok, revision} ->
String.trim(revision)

{:error, :enoent} ->
{revision, 0} = System.cmd("git", ["log", "-1", "--format=%h"])
String.trim(revision)
end

config :ae_mdw, build_revision: mdw_revision

# Database
node_root = System.get_env("NODEROOT", "../aeternity/_build/local/")

Expand Down
4 changes: 4 additions & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ config :logger,
config :phoenix, :stacktrace_depth, 20
config :phoenix, :plug_init_mode, :runtime

# Stat
{revision, 0} = System.cmd("git", ["log", "-1", "--format=%h"])
config :ae_mdw, build_revision: String.trim(revision)

# Dev tools
if File.exists?(Path.join([__DIR__, "dev.tools.exs"])) do
import_config "dev.tools.exs"
Expand Down
2 changes: 2 additions & 0 deletions config/prod.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Config

config :ae_mdw, build_revision: String.trim(File.read!("AEMDW_REVISION"))

# Endpoint
port = String.to_integer(System.get_env("PORT") || "4000")

Expand Down
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ config :logger, level: :warn
config :logger,
backends: [LoggerJSON, {LoggerFileBackend, :info}]

# Stat
config :ae_mdw, build_revision: "abcd1234"

config :logger_json, :backend,
metadata: [:request_id],
json_encoder: Jason,
Expand Down
5 changes: 3 additions & 2 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ services:
ae_mdw:
build:
context: .
dockerfile: ./Dockerfile.dev
dockerfile: ./Dockerfile
args:
MIX_ENV: dev
RUNNER_IMAGE: "hexpm/elixir:1.13.4-erlang-23.3.4.18-debian-bullseye-20220801"
USER: root
image: aeternity/ae_mdw_dev:latest
ports:
- "4000:4000" #MDW's default port
- "4001:4001" #MDW's websocket default port
- "3113:3113" #Node's default internal API port
- "3013:3013" #Node's default external API port
- "3014:3014" #Node's channels default websocket port
entrypoint: /home/aeternity/node/ae_mdw/entrypoint.sh
volumes:
- ${PWD}/data/mnesia:/home/aeternity/node/local/rel/aeternity/data/mnesia
- ${PWD}/data/mdw.db:/home/aeternity/node/local/rel/aeternity/data/mdw.db
Expand Down
14 changes: 7 additions & 7 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ services:
ae_mdw:
build:
context: .
dockerfile: ./Dockerfile.dev
dockerfile: ./Dockerfile
args:
MIX_ENV: test
image: aeternity/ae_mdw_test:latest
entrypoint: ""
RUNNER_IMAGE: "hexpm/elixir:1.13.4-erlang-23.3.4.18-debian-bullseye-20220801"
USER: root
image: ae_mdw_test:latest
command: ./scripts/test.sh
working_dir: /app
volumes:
- ${PWD}/docker/aeternity.yaml:/home/aeternity/aeternity.yaml
- ${PWD}/priv:/home/aeternity/node/ae_mdw/priv
- ${PWD}/test:/home/aeternity/node/ae_mdw/test
- ${PWD}/scripts/test.sh:/home/aeternity/node/ae_mdw/test.sh
- ${PWD}:/app
environment:
- AETERNITY_CONFIG=/home/aeternity/aeternity.yaml
1 change: 1 addition & 0 deletions rel/env.sh.eex
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

export RELEASE_MODE=interactive
export RELEASE_NODE=aeternity@localhost
2 changes: 1 addition & 1 deletion scripts/do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME="aeternity@localhost"

case $1 in
"shell")
mix deps.get
mix local.hex --force && mix local.rebar --force && mix deps.get
iex --sname $NAME -S mix phx.server
;;

Expand Down
1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -xe

mix local.hex --force && mix local.rebar --force && mix deps.get
elixir --sname aeternity@localhost -S mix test

exit 0

0 comments on commit a133ea4

Please sign in to comment.