Search code examples
swift3gitlabgoogle-compute-enginecontinuous-deploymentvapor

Gitlab - Google compute engine Continuous delivery


What I am trying to do is to enable Continuous delivery from GitLab to my compute engine on Google Cloude. I have Ubuntu 16.04 TSL running over there. I did install all components needed to run my project like: Swift, vapor, nginx. I have manage to install Gitlab runner as well and created a runner whcihc is accessible from my gitlab repo. Everytime I do push on master the runner triggers. What happen is a failure due to:

could not create leading directories of '/home/gitlab-runner/builds/2bbbbbd/0/Server/Packages/vapor.git': Permission denied

If I change the permissions to chmod -R 777 It will hange on running for build stage visible on gitlab pipeline.

I did something like: sudo chown -R gitlab-runner:gitlab-runner /home/gitlab-runner/builds sudo chown -R gitlab-runner:gitlab-runner /home/gitlab-runner/cache but this haven't help, the error is same Permission denied

Below you have my .gitlab-ci.yml

before_script:
  - swift --version

stages:
  - build
  - deploy

job_build:
  stage: build
  before_script:
  - vapor clean
  script:
  - vapor build --release
  only:
  - master

job_run_app:
  stage: deploy
  script:
    - echo "Deploy a  API"
    - vapor run --name=App --env=production
  environment:
    name: production

job_run_frontend:
  stage: deploy
  script:
    - echo "Deploy a  Frontend"
    - vapor run --name=Frontend --env=production
  environment:
    name: production

But that haven't pass to next stage eg. deploy. I had waited more then 14h for that but with out result. And... I have few more questions:

  1. Gitlab runner creates builds under location /home/gitlab-runner/builds/ in this location every new job have own folder. for eg. /home/gitlab-runner/builds/2bbbbbd/ in which is my project and the commands are executed. So what happens when the first one is running and I do deploy new version? the ports are blocked by the first instance and so on?
  2. If I want to enable supervisor how do I do that with this when every time I deploy folder is different?
  3. Can anyone explain or show me or point me to tutorial how do Continuous deployment with out docker?

Solution

  • How to start a service using GitLab runner

    Thanks to long deep search I finally found an answer! The full article can be found above.

    Briefly GitLab CI documentation recommends using dpl for deployment. Gitlab runner run test and process should end. The runner is designed to kill all created processes after finishing each build. The GitLab runner is unable to perform operations outside the catalogue.