GoCD Copy dist folder to host system

240 Views Asked by At

I have a GoCD instance running inside a docker container. I want to build an angular2 project by angular-cli through the pipeline of GoCD. This works well, but I need to copy the built dist folder from the docker container to "/var/www/html/" folder on the host system.

Im very new to GoCD and docker. Can anyone help me?

Edit: One more questions is: where is the dist folder located after build finished?

2

There are 2 best solutions below

3
On

Easy solution would be to bind mount local /var/www/html somewhere inside of your container and copy those files to that mounted directory which is now accessible from your container.

How you can create the bind mount depends on how you are launching your container (docker cli or docker-compose...)

if you are using docker cli, you can use -v switch

docker run -v /var/www/html:/somwhere/in/your/container ...

example in docker-compose

version: "3.8"
services:
  name-of-your-service:
    image: name-of-your-image
    volumes:
       - /var/www/html:/somwhere/in/your/container 
    ...
0
On

Follow following steps to copy a file from an image.

  1. Create a dummy container
    docker create -ti --name "container_name" "docker_iamge_from_which_you_want_to_copy_file" bash docker_iamge_from_which_you_want_to_copy_file is your image name.

  2. copy file from dummy continer to your local path
    docker cp "container_name":"path_in_image" "local_path"

in your case local_path is /var/www/html/ and path_in_image is your dist location inside your container.