angular - 使用 docker 容器中的 startup.sh 文件构建具有动态环境的 Angular 应用程序
问题描述
所以我使用 gcloud run 来部署我的 docker 容器和我的 Angular 应用程序。这是我的文件结构:
在我的 docker 文件夹中有一个我想运行的 startup.sh 文件。
我的 dockerfile 看起来像这样:
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
FROM tiangolo/node-frontend:10 as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY ./ /app/
RUN npm run build -- --output-path=./dist/out
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.15
COPY --from=build-stage /app/dist/out/ /usr/share/nginx/html
# Copy the default nginx.conf provided by tiangolo/node-frontend
COPY --from=build-stage /nginx.conf /etc/nginx/conf.d/default.conf
COPY ../docker /app/
WORKDIR /app/docker
RUN /startup.sh
当 gcloud 运行我的 dockerfile 时,我总是收到此错误:
/bin/sh: 1: /startup.sh: not found
所以我想我的 docker 文件夹副本没有像我认为的那样正常工作,或者我可能不在正确的文件夹中。我对 docker 很陌生,所以我可能在这里错过了一些非常基本的东西。
解决方案
尝试添加绝对路径。
确保在容器中安装了 bash。
添加执行文件的权限。
尝试使用CMD
.
COPY /docker /app/
RUN apk add --no-cache bash
RUN chmod +x /app/docker/startup.sh
# RUN /app/docker/startup.sh
CMD ["/bin/bash", "-c", "/app/docker/startup.sh"]
推荐阅读
- c# - admob 插页式回调事件只工作一次,而不是第二次
- html - display:grid 不能在 chromium 和 nwjs 中的按钮元素上工作,在 Firefox 中工作正常
- javascript - jQuery:一个按钮,它检查自己的 DIV 中的所有复选框并取消选中所有其他复选框
- python - Pycharm代码完成窗口中带有数字的绿色和红色箭头
- javascript - VueJS - 由于其 MIME 类型而未加载 CSS
- macos - 为什么(macOS)grep 在递归搜索时似乎在等待标准输入?
- linux - curl 在一个命令中提交基本身份验证和网站用户身份验证
- r - 根据一个数据帧中的 NA 外观比较两个数据帧结果
- java - 计算特定歌曲在播放列表中收听的次数
- php - 具有天数和用户数组合的php数组