1

我正在构建一个生产 docker 映像,但是当我运行它时,我得到:

2018-10-06 14:14:20.950098 Error in process ~p with exit value:~n~p~n
    <0.670.0>
    {function_clause,[{filename,join,[[]],[{file,"filename.erl"},{line,432}]},{code_server,insert_dir,2,[{file,"code_server.erl"},{line,820}]},{code_server,init_namedb,2,[{file,"code_server.erl"},{line,797}]},{code_server,init_namedb,1,[{file,"code_server.erl"},{line,793}]},{code_server,init,3,[{file,"code_server.erl"},{line,96}]}]}

不是 erlang 人,但这似乎是期望加载 code_server,但我在 dev.exs 和 prod.exs 中禁用了它。这是我的 rel/config.exs:

# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
~w(rel plugins *.exs)
|> Path.join()
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,
    # This sets the default release built by `mix release`
    default_release: :default,
    # This sets the default environment used by `mix release`
    default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/config/distillery.html


# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
  # If you are running Phoenix, you should make sure that
  # server: true is set and the code reloader is disabled,
  # even in dev mode.
  # It is recommended that you build with MIX_ENV=prod and pass
  # the --env flag to Distillery explicitly if you want to use
  # dev mode.
  set dev_mode: true
  set include_erts: false
  set cookie: :"***********************"
end

environment :prod do
  set include_erts: true
  set include_src: false
  set cookie: :"***********************"
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :app do
  set version: current_version(:app)
  set applications: [
    :runtime_tools
  ]
end

release :app_web do
  set version: current_version(:app_web)
  set applications: [
    :runtime_tools
  ]
end

这是我的 Dockerfile:

####### BUILDER STAGE #########

ARG FROM=registry.mydomain.com/proj/proj/phoenix:master
FROM ${FROM} as builder
MAINTAINER Ron Arts <ron.arts@gmail.com>

WORKDIR ${HOME}
ADD . ${HOME}

RUN set -x \
 && mix do deps.get, credo --strict 

ENV MIX_ENV=prod

RUN set -x \
 && mix phx.digest \
 && mix release --env=prod 

RUN find /root/_build -name \*.gz

####### PACKAGER STAGE ##########

FROM alpine:3.6

# RUN apk add --no-cache ca-certificates openssl ncurses unixodbc zlib
RUN apk add --no-cache ncurses openssl bash

ENV VERSION 0.0.1
COPY --from=builder /root/_build/prod/rel/app/releases/$VERSION/app.tar.gz /app/app.tar.gz
WORKDIR /app
RUN tar -zxf app.tar.gz
WORKDIR /app/releases/$VERSION
ENTRYPOINT ["./app.sh"]
CMD ["foreground"]
# Start up in 'foreground' mode by default so the container stays running

我的 prod.exs:

config :project_web, Project.Endpoint,
  load_from_system_env: true,
  url: [host: "example.com", port: 80],
  cache_static_manifest: "priv/static/cache_manifest.json",
  server: true,
  code_reloader: false

这是我的主要部门:

  defp deps do
    [
      {:credo, "~> 0.10.0", only: [:dev, :test], runtime: false},
      {:distillery, "~> 2.0"}
    ]
  end

(这是一个总括项目)。

所以我的问题是:这条消息实际上意味着什么,如何修复它?我可以尝试什么?

4

1 回答 1

1

事实证明这是酿酒厂的一个错误。有一种解决方法。将以下内容放入 Dockerfile(api应用程序名称在哪里):

ENV VERSION 0.1.0
ENV CONSOLIDATED_DIR /app/releases/$VERSION/lib/api-$VERSION/consolidated

另请参阅此 github 问题:Application release runs using 'start', but not 'foreground', or 'console' commands

于 2018-11-15T10:05:55.610 回答