steps:
# build the container image
- name: gcr.io/cloud-builders/docker
args: [ build, -t, gcr.io/<project name here>/<container name here>, . ]
# push the container image to Container Registry
- name: gcr.io/cloud-builders/docker
args: [ push, gcr.io/<project name here>/<container name here> ]
# Deploy container image to Cloud Run
- name: gcr.io/cloud-builders/gcloud
args: [ beta, run, deploy, <container name here>, --image, gcr.io/<project name here>/<container name here>, --platform, managed, --region, us-central1 ]
images:
- gcr.io/<project name here>/<container name here>
FROM node:10.9-alpine AS build-stage
WORKDIR /app
COPY . .
RUN npm install && npm run build --prod
FROM nginx:latest
COPY /etc/nginx/*.conf /etc/nginx/
## Create the new /var/logs/nginx folder
RUN mkdir /var/logs
RUN mkdir /var/logs/nginx
## Copy a new configuration file setting listen port to 8080
COPY /etc/nginx/conf.d/*.conf /etc/nginx/conf.d/
## Expose port 8080
EXPOSE 8080
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From 'build' stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=build-stage /app/dist/* /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
# Node
node_modules/
# Angular
dist/
Step #0: Step 6/13 : COPY /etc/nginx/*.conf /etc/nginx/
Step #0: COPY failed: no source files were specified
Finished Step #0
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR: (gcloud.builds.submit) build 731c37fb-f282-4649-972e-aec572b33bca completed with status "FAILURE"
我在这里想念什么?任何线索都将受到高度赞赏。
答案 0 :(得分:0)
据此:
Step #0: Step 6/13 : COPY /etc/nginx/*.conf /etc/nginx/
Step #0: COPY failed: no source files were specified
问题是您使用COPY
命令。使用COPY /etc/nginx/*.conf /etc/nginx/
时,应确保要复制的文件在构建上下文中。因此,您应该做的是确保* .conf文件位于正确的目录中。它应该看起来像这样:
/etc/nginx/*.conf
/etc/Dockerfile
或者这样:
/etc/nginx/folderName/*.conf
/etc/nginx/Dockerfile
另一种方法是使用VOLUME
而不是COPY
。 VOLUME
的作用是将所需目录装载到容器内的目录。它本身不会复制文件,而是创建对实际目录的“引用”。
安装音量(-v,-只读)
$ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
-v
标志将当前工作目录安装到容器中。 -w
通过将目录更改为pwd
返回的值,使命令在当前工作目录中执行。因此,此组合使用容器在当前工作目录中执行命令。
一些有关Dockerfile的有用链接:
请告诉我这是否有帮助。