简体   繁体   English

Docker & gitlab-ci:在 Dockerfile 中构建应用程序,同时创建工件

[英]Docker & gitlab-ci: Build application in Dockerfile but also create artifact

I have a Dockerfile which builds my web application and then moves the built application to an nginx folder such that I only have to start the docker image locally and then access my application via localhost (I left out any details because for the moment I don't think they are necessary). I have a Dockerfile which builds my web application and then moves the built application to an nginx folder such that I only have to start the docker image locally and then access my application via localhost (I left out any details because for the moment I don' t认为它们是必要的)。

Now the problem is that I would also like to create an artifact in the gitlab-ci pipeline with the same Dockerfile.现在的问题是我还想在 gitlab-ci 管道中创建一个具有相同 Dockerfile 的工件。 This artifact basically is the built application which is then processed later on.这个工件基本上是构建的应用程序,然后稍后处理。

How can I "copy" the application folder from inside the Dockerimage to the gitlab-ci environment?如何将 Dockerimage 中的应用程序文件夹“复制”到 gitlab-ci 环境中?

Edit: I found编辑:我发现

script:
    - docker container create --name dummy ${IMAGE}
    - docker cp dummy:/usr/share/nginx/html web
    - docker rm -f dummy
artifacts:
    paths:
        - web

to be a solution.成为一个解决方案。

My solution:我的解决方案:

script:
    - docker container create --name dummy ${IMAGE}
    - docker cp dummy:/usr/share/nginx/html web
    - docker rm -f dummy
artifacts:
    paths:
        - web

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM