Problem: How can I copy a file from the host to the container from inside the running container?
TL;TR:
Idea: I am using a gitlab server and I want to use Gitlab-ci in order to
1. test the commits
2. gather all the source files in a .tar
3. and finally deploy them to another server
Current Status: I have the previous 3 jobs defined in my .gitlab-ci.yml. 1 and 2 work just fine, but rsync throws a "Host key verification failed." error of course. Here is my "thinned out" version of my .gitlab-ci.yml file:
image: alpine
stages:
- test
- package
- deploy
test:
stage: test
script: bla bla testing bla bla
package:
stage: package
script: tar -cvf source.tar htdocs
deploy:
stage: deploy
before_script:
- apk update
- apk add rsync openssh
script:
- rsync -vuar source.tar [email protected]:/home/servadmin/transfer
I have no access to these containers other than this .yml file so I really need to find a way to copy the public key from the host to the container, but I have to do that from inside the container. Or I could use multi-runners etc etc but I am new to ci and I could avoid that for the moment