I'm deploying a Django project on Centos 7 server using gitlab runner.
Each time I commit and push the project, gitlab runner tries to remove folders (such as the media folder) that are not in the gitlab repository(are on .gitignore).
I don't want gitlab runner to delete media files.
How can I ignore deleting some files and folders when gitlab runner starts its job?
Thanks in advance.
I found the answer.
I've put the media folder inside
the project in the root static/media,
so every time gitlab runner deletes all the files and folders that are not in the project directory in the gitlab (also the media folder).
Simply, I put that media folder outside
of the project.
former MEDIA_ROOT in settings.py:
MEDIA_ROOT= os.path.join(BASE_DIR, 'static/media/')
changed it to:
MEDIA_ROOT = '/home/gitlab-runner/builds/path-to-some-folder-outside-of-the-project-root/media/'
former nginx configuration:
location /media/ {
alias /home/gitlab-runner/builds/path-to-my-project/static/media/ ;
}
changed to:
location /media/ {
alias /home/gitlab-runner/builds/path-to-some-folder-outside-of-the-project-root/media/ ;
}
Hope it helps anybody that has this problem.