I shared a volume between Angular app and Nginx to serve app's generated files. At 1st startup everything is fine: Angular build goes successfully and Nginx serves created files.
我在角度应用程序和Nginx之间共享了一卷,以提供应用程序生成的文件。在第一次启动时,一切都很好:ANGLE构建成功,Nginx提供创建的文件。
But when I update image to make new build the files in shared folder aren't overwritten with newly built and Nginx serves old build.
但是,当我更新镜像以进行新的构建时,共享文件夹中的文件不会被新构建的文件覆盖,而Nginx提供旧的构建。
I have
我有过
- app-client:/var/www
in volumes section of "nginx" service and
在“nginx”服务的卷数部分和
- app-client:/app/dist
in volumes section of "app" service in my docker-compose.yml
在我的docker-compose.yml中的“app”服务的卷部分
Angular outputs built files in /app/dist directory.
ANGLE输出/app/dist目录中的构建文件。
What am I missing? Thanks
我遗漏了什么?谢谢
更多回答
That is in fact a major challenge when trying to use named volumes to publish files from one container to another. Can you COPY
the files into the Nginx-based image (maybe using a multi-stage build; maybe without a dedicated Angular container), instead of using a volume?
事实上,在尝试使用命名卷将文件从一个容器发布到另一个容器时,这是一个重大挑战。您是否可以将文件复制到基于nginx的映像中(可能使用多阶段构建;可能不使用专用的角度容器),而不是使用卷?
优秀答案推荐
Okay I found out that shared volumes unavailable on build phase but can be used in startup .sh script. So I added rm & cp commands to cleanup volume dir and copy app files into it. And finally it worked.
好的,我发现共享卷在构建阶段不可用,但可以在启动.sh脚本中使用。因此,我添加了rm&cp命令来清理卷目录并将应用程序文件复制到其中。最后,它奏效了。
更多回答
我是一名优秀的程序员,十分优秀!