I need to copy one file from the project to the server where the application will be deployed. This must be done before deploying the application.
At the moment, I can connect to the server and create the folder I need there. But how to put the necessary file there?
The stage in which this should be done.
deploy_image:
stage: deploy_image
image: alpine:latest
services:
- docker:20.10.14-dind
before_script:
- chmod og= $ID_RSA
- apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no root@$SERVER_IP
docker login -u $REGISTER_USER -p $REGISTER_PASSWORD $REGISTER
script:
- ssh -i $ID_RSA -o StrictHostKeyChecking=no root@$SERVER_IP
mkdir $PROJECT_NAME || true
- ssh -i $ID_RSA -o StrictHostKeyChecking=no root@$SERVER_IP
cd $PROJECT_NAME
# here you need to somehow send the file to the server
after_script:
- ssh -i $ID_RSA -o StrictHostKeyChecking=no root@$SERVER_IP docker logout
- ssh -i $ID_RSA -o StrictHostKeyChecking=no root@$SERVER_IP exit
only:
- main
Help me please.
2
Answers
Use
rsync
:Alternatively (to
rsync
), usescp
(which, sincessh
package is installed, should come with it)That way, no additional
apk update/add
needed.