Search code examples
gitlabgitlab-cilampgitlab-ci-runner

GitLab CI/CD - setup for LAMP project


We have a regular LAMP project and we recently to moved to Gitlab (instead of Github).

Previously we have been using Jenkins for deployment, now I am planning to migrate it to Gitlab CI/CD.

We have servers A and B (with Loadbalancer) for development version and servers C and D (likewise, with LB) for production environment.

Since it's a LAMP project, the deploy is as simple as that: - latest changes are pulled from repo; - all changed files are rsynced into public web folder; - some utilities like composer and npm are run.

Basically I need to deploy changes to two development VPS and two production ones.

Do I have to install and start runner on each of them? Or is there a more efficient approach?


Solution

  • There are many approaches possible (I'm assuming your are running on unix) :

    • Simply create a new server and install the gitlab-runner on it and register it. Install the dependencies on the server itself.
    • If you are confident with docker, I suggest you to install it as Docker service. For the dependencies, create a docker image adding the utilies and refers the container image in the config.toml advanced configuration with the --image flag. This will trigger a container based on your image for every build.
    • If you know Kubernetes, use kubernetes executor and build directly on the cluster. You still need to build your own image with dependencies and refers it in the runner configuration with --kubernetes-image

    For the deployment, just copy the files on your target servers after the build using tools like scp or rsync. Better (if your LAMP project is dockerized) : build a docker image, push it on a registry and pull it on your server. Even better : deploy all the containers in a orchestrator like Kubernetes.