0

I'm trying to use GitLab CI/CD feature with my Django project. Is it possible to run this Django project with GitLab runner without Docker so after every git push server is started again? At this moment server is running but after git push it is not restarted but it creates new job instance again.

I have tried to make some basic .gitlab-ci.yml file but after I push updates to master the job is running and never ending. I can reach the server website but when I want to update something else to master new job is created and the previous does not automatically end.

script:
    - python3.6 manage.py runserver --noreload 0.0.0.0:8001 >/dev/null

I think this line where I'm trying to runserver is most likely wrong.

1 Answers1

0

I found a solution to achieve GitLab CI/CD feature for running a Django instance by using Apache in following steps below.

1. Firstly, I configured .gitlab-ci.yml file to restart Apache after change on master branch:

stages:
    - name_of_my_stage 
job-my_job:     
    stage: name_of_my_stage     
    script:
        - service httpd restart
    only: 
        - master

More info about configuration possibilities of this file or GitLab CI/CD can be found in their documentation GitLab CI/CD pipeline documentation.

2. Secondly, you need to configure Apache to run Django instance as described in this answer for example multiple django sites with apache & mod_wsgi or in this tutorial by DigitalOcean How to for setting up Apache to serve up Django where you need to skip to Configuring Apache section.