gpt4 book ai didi

docker - AWS Elastic Beanstalk Docker不支持多阶段构建

转载 作者:行者123 更新时间:2023-12-02 17:31:55 24 4
gpt4 key购买 nike

我正在努力将我的构建部署到Docker上的AWS上。我不知道解决方案在哪里,因为这是我第一次使用Docker。我已经在本地一切正常,但是当我部署时,在Elastic Beanstalk中出现以下错误:

2020/04/30 05:35:02.330900 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: failed to pull docker image: Command /bin/sh -c docker pull node:13.3.0 AS compile-image failed with error exit status 1. Stderr:"docker pull" requires exactly 1 argument.
See 'docker pull --help'.

这是我的Docker文件的样子:
FROM node:13-alpine as builder

WORKDIR /opt/ng
COPY package.json package-lock.json ./
RUN npm install

ENV PATH="./node_modules/.bin:$PATH"

COPY . ./
RUN ng build --prod

FROM nginx:1.18-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /opt/ng/dist/angular-universal-app/browser /usr/share/nginx/html

有人能指出我正确的方向吗?还是Elastic Beanstalk的Docker版本不支持这种多阶段构建方法?

最佳答案

我有同样的问题。
实际上,我在日志文件中检查以下行:

2020/05/26 17:26:30.327310 [INFO] Running command /bin/sh -c docker pull node:alpine as builder
2020/05/26 17:26:30.369280 [ERROR] "docker pull" requires exactly 1 argument.

如您所见,它尝试使用3个参数进行“docker pull”:
  • 节点: Alpine
  • 作为
  • 构建器

  • 当然,这是不可能的,因为它只需要一个参数。因此,显然,AWS Elastic Beanstalk不支持阶段命名。出于这个原因,我使用一个未命名的构建器解决了:
    FROM node:13-alpine

    最后:
    COPY --from=0 /opt/ng/dist/angular-universal-app/browser /usr/share/nginx/html

    最终的Dockerfile:
    FROM node:13-alpine

    WORKDIR /opt/ng
    COPY package.json package-lock.json ./
    RUN npm install

    ENV PATH="./node_modules/.bin:$PATH"

    COPY . ./
    RUN ng build --prod

    FROM nginx:1.18-alpine
    COPY nginx.conf /etc/nginx/conf.d/default.conf
    COPY --from=0 /opt/ng/dist/angular-universal-app/browser /usr/share/nginx/html

    对我来说,它可以使用该解决方案。如果有人有任何问题,请共享最近的100行日志

    关于docker - AWS Elastic Beanstalk Docker不支持多阶段构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61518512/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com