docker build 命令的 --target 选项在 aws codeBuild 中不起作用

Sou*_*aye 5 amazon-web-services docker dockerfile aws-codebuild

我为我的 aws codeBuild 使用多阶段 docker 构建来构建我的应用程序。我的 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
...
Run Code Online (Sandbox Code Playgroud)

为了构建我的生产应用程序,我使用 aws buildspect.yml ,在此文件中我有以下命令:

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
...
Run Code Online (Sandbox Code Playgroud)

该命令效果不太好,因为所有阶段都按以下顺序执行:依赖项、liveProduction、liveDevelopment。在这种情况下,我只想执行依赖项和 liveDevelopment。

我想知道是什么问题?为什么 docker build 的 --target 选项在 codeBuild 中不起作用?

谢谢。

BMi*_*tch 3

Skipping build stages is a feature of buildkit that creates a dependency graph. 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_BUILDKIT=1 docker build --no-cache --target liveProduction -t app-facej-backoffice .
Run Code Online (Sandbox Code Playgroud)