我正在构建生产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}]}]}
不是一个有过失的人,但是这似乎正在加载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
(这是一个总括项目)。
所以我的问题是:此消息实际上是什么意思,如何解决它?我可以尝试什么?
答案 0 :(得分: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