简体   繁体   English

--docker 构建命令的目标选项在 aws codeBuild 中不起作用

[英]--target option of docker build command doesn't work in aws codeBuild

I use a multi stages docker build for my aws codeBuild to build my application.我使用多阶段 docker 构建我的 aws codeBuild 来构建我的应用程序。 The shape of my docker file is:我的 docker 文件的形状是:

FROM strapi/base:14-alpine AS dependencies
...

FROM strapi/base:14-alpine As liveProduction
ENV NODE_ENV="production"
COPY --from=dependencies /toto /toto
....

FROM strapi/base:14-alpine As liveDevelopment
ENV NODE_ENV="development"
COPY --from=dependencies /toto /toto
...

And to build my application for production, i use aws buildspect.yml and in this file i have the following comande:为了构建我的生产应用程序,我使用 aws buildspect.yml 并且在这个文件中我有以下命令:

docker build --no-cache --target liveProduction -t app-facej-backoffice .

This command doesn't work very well, because, all stages are executed with the following order: dependencies, liveProduction, liveDevelopment.此命令效果不佳,因为所有阶段都按以下顺序执行:dependencies、liveProduction、liveDevelopment。 In this case, i want only dependencies and liveDevelopment to be executed.在这种情况下,我只想执行 dependencies 和 liveDevelopment。

I would like to know what is the problem?我想知道是什么问题? Why the --target option of docker build doesn't work in codeBuild?为什么 docker build 的 --target 选项在 codeBuild 中不起作用?

Thanks.谢谢。

Skipping build stages is a feature of buildkit that creates a dependency graph.跳过构建阶段是 buildkit 的一个特性,它创建了一个依赖图。 This is the default in newer versions of docker, so either the release of docker doesn't have buildkit, or you need an environment variable ( DOCKER_BUILDKIT=1 ) set to enable it:这是 docker 的较新版本中的默认设置,因此 docker 的版本没有 buildkit,或者您需要设置一个环境变量 ( DOCKER_BUILDKIT=1 ) 来启用它:

DOCKER_BUILDKIT=1 docker build --no-cache --target liveProduction -t app-facej-backoffice .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM