给出这个多阶段构建的小例子
<html>
<head>
<title>Preload Images example</title>
</head>
<body>
<div><canvas id="myCanvas" width="960" height="400"></canvas></div>
<script src="https://code.createjs.com/1.0.0/easeljs.min.js"></script>
<script type="text/javascript" src="https://code.createjs.com/1.0.0/preloadjs.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var canvas = document.getElementById("myCanvas");
var stage = new createjs.Stage(canvas);
var manifest;
var preload;
var progressText = new createjs.Text("", "20px Arial", "#dd4814");
progressText.x = 125 - progressText.getMeasuredWidth() / 2;
progressText.y = 20;
stage.addChild(progressText);
stage.update();
function setupManifest() {
manifest = [
{
src: "https://s3.amazonaws.com/coursetro/stuff/mountains-clouds.jpg",
id: "image1"
},
{
src: "https://s3.amazonaws.com/coursetro/stuff/adventure-alpine-alps-714258.jpg",
id: "image2"
},
{
src: "https://s3.amazonaws.com/coursetro/stuff/170407220921-07-iconic-mountains-pitons-restricted.jpg",
id: "image3"
},
{
src: "https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg",
id: "image4"
}
];
}
function startPreload() {
preload = new createjs.LoadQueue(true);
preload.installPlugin(createjs.Sound);
preload.on("fileload", handleFileLoad);
preload.on("progress", handleFileProgress);
preload.on("complete", loadComplete);
preload.on("error", loadError);
preload.loadManifest(manifest);
}
function handleFileLoad(event) {
console.log("loading: " + event.item.type);
if(event.item.id == "image1"){
}
}
function loadError(evt) {
console.log("err",evt.text);
}
function handleFileProgress(event) {
progressText.text = "loading " + (preload.progress*100|0) + " %";
stage.update();
}
function loadComplete(event) {
}
setupManifest();
startPreload();
</script>
</body>
</html>
为什么这会在本地文件系统上生成3张图像?
FROM node:10 AS ui-build
WORKDIR /usr/src/app
FROM node:10 AS server-build
WORKDIR /root/
EXPOSE 3070
ENTRYPOINT ["node"]
CMD ["index.js"]
我希望有两个映像,即基础映像和服务器构建映像。我使用了标准的docker build命令,即
"<none>";"<none>";"58d63982fbef";"2020-04-15 17:53:14";"912MB"
"node";"10";"bd83fcefc19d";"2020-04-14 01:32:21";"912MB"
"test";"latest";"3913dd4d03b6";"2020-04-15 17:53:15";"912MB"
那么图像的哪一部分是空的,哪些是测试的?
我很困惑
答案 0 :(得分:2)
Dockerfile中以FROM
行开头的每个块都会创建一个新映像。如果使用docker build -t
选项,则只有最后一个阶段会使用您指定的名称进行标记;其余的块将在<none>
输出之类的地方显示为docker images
。
# node:10 is a base image
# Not the final image, will appear as <none>:<none>
FROM node:10 AS ui-build
...
# The final image, will appear as test:latest (`docker build -t` option)
FROM node:10 AS server-build
...
您偶尔会看到Dockerfile,其中在以后的构建阶段中会重复使用基础映像,并且在docker images
输出中根本不会显示该映像。
# Will be hidden because it has descendant images
FROM node:10 AS base
RUN apt-get update && apt-get upgrade
# Will appear as <none>:<none>
FROM base AS ui
...
# Will get the `docker build -t` tag
FROM base