Home > Blockchain >  Using rsync with gitlab-ci how to deploy identically?
Using rsync with gitlab-ci how to deploy identically?

Time:12-15

when I push and that, on my server, I don't have my project, everything is fine (obviously):

rsync --exclude=".git" -e ssh -avz --delete-after . $SSH_USER@$SSH_HOST:blog_symfony/
building file list ... done
created directory blog_symfony
[...]
sent 44,533,927 bytes  received 5,523 bytes  5,239,935.29 bytes/sec
total size is 238,959,003  speedup is 5.37

the problem when I push a 2nd time, it does anything to me:

rsync: [generator] delete_file: rmdir(project/blog_symfony/project/blog_symfony) failed: Permission denied (13)
rsync: [generator] delete_file: rmdir(project/blog_symfony) failed: Permission denied (13)
deleting project/blog_symfony/translations/.gitignore
deleting project/blog_symfony/translations/
[...]

it creates for me, on my server side, a 'project' folder in the blog_symfony folder

annot delete non-empty directory: project/blog_symfony
cannot delete non-empty directory: project
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
sent 13,924 bytes  received 175 bytes  28,198.00 bytes/sec
total size is 238,959,004  speedup is 16,948.65
Cleaning up project directory and file based variables 00:01

ERROR: Job failed: exit code 1

my gitlab-ci:

before_script:
        - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
        - eval $(ssh-agent -s)
        - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
        - mkdir -p ~/.ssh
        - chmod 700 ~/.ssh
        - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
    script:
        - ls
        - apt-get update && apt-get install rsync -y
        - ssh $SSH_USER@$SSH_HOST "ls"
        - rsync --exclude=".git" -e ssh -avz --delete-after . $SSH_USER@$SSH_HOST:blog_symfony/
        - ssh $SSH_USER@$SSH_HOST "cd blog_symfony && docker-compose build && docker-compose up"

in ls -l I have a folder written by rsync and which is impossible to remove from gitlab-ci:

drwxrwxr-x 3 root                     root                        4096 Dec 14 23:26  project

I don't think this is normal. This is the first time that I use gitlab-ci for a symfony project.

Thank you for your help

CodePudding user response:

ls -l: I have a folder written by rsync and which is impossible to remove from GitLab CI.

Check if that folder is instead created after the first execution of your docker-compose up: if your Docker image execute itself internally as USER root, using a bind mount, it would write files/folders as root.
And that would impede normal operation (on the server, outside the container), like your rsync, because root files would be i the way.

  • Related