简体   繁体   中英

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).

Now the problem is that I would also like to create an artifact in the gitlab-ci pipeline with the same 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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