I have create a simple Django application, then I have commit and push to Gitlab. Finally I would like to install that application on my "production server" which is running ubuntu so from that server terminal I run the command:
git clone https://domain.com/path/to/git
I cannot find my python code among the file cloned.
What is the correct way to get the python code from the gitlab repository?
First of all,
does your git has all source code including the pip installed apps?
Well i don't know about gitlab, and there's basically everything missing about your configuration on the server, but you can set up a git hook on a git repo.
here is and example of a post-receive hook to deploy an example django project.
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "master branch received, deploying..."
GIT_WORK_TREE="/PATH/TO/DJANGO/PROJECT" git checkout -f master > /dev/null
source /PATH/TO/DJANGO/VIRTUAL/ENVIRONMENT/bin/activate > /dev/null
echo "installing new pip dependencies..."
pip install -r /PATH/TO/DJANGO/PROJECT/dependencies.txt > /dev/null
echo "applaying new db migrations..."
python /PATH/TO/DJANGO/PROJECT/manage.py migrate_schemas > /dev/null
deactivate > /dev/null
touch /PATH/TO/DJANGO/PROJECT/PROJECT_NAME/wsgi.py > /dev/null
echo "Sever code reloaded."
else
echo "Received branch $ref, not deploying."
fi
done
so a few thing to consider:
chmod +x FILE_NAME
pip freeze > dependencies.txt
(note, everything on the file will be insatled on the server) touch wsgi.py
would reload the code if your running apache with mod_wsgi on daemon mode ( more info ) 问题是分支,我解决了选择一个特定的分支,应用选项“-b”后跟正确的分支名称“develop”:
git clone -b develop https://example.com/username/projectname.git
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.