我有一个包含两个阶段的docker文件,可在本地成功构建。当我尝试将其推送到heroku的容器服务时,它无法构建,并显示文件不可用的错误。
错误
#include <iostream>
#include <vector>
int main() {
// coefs before multiplying by powers of A
std::vector<int> a = {1,2,1};
// make polynomial coefs vector
int A = 1;
const int as = a.size();
int ap = 1;
for(int ai = 0; ai<as; ++ai){
a[ai] *= ap;
ap *= A;
}
std::vector<int> b = {1,3,3,1};
const int bs = b.size();
// result vector
std::vector<int> c(as + bs - 1, 0);
// multiply vectors
for(int ai = 0; ai<as; ++ai)
for(int bi = 0; bi<bs; ++bi){
c[ai+bi] += a[ai]*b[bi];
}
for(int cn: c)
std::cout << cn << ' ';
return 0;
}
Dockerfile
** (Mix.Config.LoadError) could not load config config/prod.exs
** (ArgumentError) argument error
:erlang.binary_to_integer("")
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
(stdlib) erl_eval.erl:236: :erl_eval.expr/5
错误发生在第二个FROM bitwalker/alpine-elixir-phoenix:1.5.2 as builder
ARG CLOAK_ENCRYPTION_KEY
ARG DATABASE_URL
ENV MIX_ENV=prod PORT=$PORT DATABASE_URL=$DATABASE_URL CLOAK_ENCRYPTION_KEY=$CLOAK_ENCRYPTION_KEY
WORKDIR /app
# Cache elixir deps
ADD mix.exs mix.lock /app/
RUN mix do deps.get, deps.compile
# Same with npm deps
ADD client/package.json client/package-lock.json /app/client/
RUN cd client && \
npm install
ADD . .
# Run frontend build, compile, and digest assets
RUN cd /app/client/ && \
npm run build && \
cd /app && \
mix do compile
RUN MIX_ENV=prod mix release --env=prod --verbose --no-tar
### Release
FROM alpine:3.8
# We need bash and openssl for Phoenix
RUN apk upgrade --no-cache && \
apk add --no-cache bash openssl
ENV SHELL=/bin/bash
COPY --from=builder /app/_build/prod/rel/myapp/app
ENTRYPOINT ["/app/bin/myapp"]
CMD ["foreground"]
是什么原因导致它在本地运行,但在Heroku上失败了?
答案 0 :(得分:2)
弄清楚了。执行heroku push时,我为每个参数都做了一个--arg
参数(Docker --build-arg
是1到1)。 Heroku实际上只想要一个--arg
,所有参数都用逗号连接。
相当于的heroku
docker build -t myapp --build-arg DATABASE_URL=someurl --build-arg CLOAK_ENCRYPTION_KEY=somekey
是
heroku container:push web --arg DATABASE_URL=someurl,CLOAK_ENCRYPTION_KEY=somekey