81 lines
2.3 KiB
Markdown
81 lines
2.3 KiB
Markdown
# GitLab CI/CD for call-center
|
|
|
|
## What this setup does
|
|
|
|
- a push to `main` triggers GitLab CI
|
|
- the job runs on a dedicated `shell` runner with tag `call-center-prod`
|
|
- the runner syncs the repository into `/home/gitlab-runner/deploy/call-center`
|
|
- Docker builds `call-center-app:<commit-sha>` and also tags `call-center-app:latest`
|
|
- `docker compose` recreates the stack from `deployment/docker-compose.server.yml`
|
|
- the public gateway container is named `call-center-app`
|
|
|
|
## Required server prerequisites
|
|
|
|
- Docker installed and running
|
|
- outbound access to `https://gitlab.konturai.kz`
|
|
- runner token from GitLab with prefix `glrt-...` or a valid project/group runner token
|
|
|
|
## Install and register the runner
|
|
|
|
Run on the target server as `root`:
|
|
|
|
```bash
|
|
cd /path/to/call-center
|
|
RUNNER_TOKEN=glrt-xxxxxxxx bash scripts/install_gitlab_runner.sh
|
|
```
|
|
|
|
The script:
|
|
|
|
- installs `gitlab-runner` from the official GitLab repository
|
|
- adds user `gitlab-runner` to the `docker` group
|
|
- creates deploy directory `/home/gitlab-runner/deploy/call-center`
|
|
- registers runner `call-center-prod-runner` with tag `call-center-prod`
|
|
|
|
If you first want to install the service without registration:
|
|
|
|
```bash
|
|
SKIP_REGISTER=1 bash scripts/install_gitlab_runner.sh
|
|
```
|
|
|
|
## Production environment file
|
|
|
|
Create the production env file once on the server:
|
|
|
|
```bash
|
|
install -m 600 /dev/null /home/gitlab-runner/deploy/call-center/.env.production
|
|
```
|
|
|
|
Then fill it with the values required by `deployment/docker-compose.server.yml`.
|
|
|
|
If the project is already running from `/root/call-center`, migrate the current env file and SQLite/files before the first CI deploy:
|
|
|
|
```bash
|
|
bash scripts/bootstrap_gitlab_deploy.sh
|
|
```
|
|
|
|
Alternative:
|
|
|
|
- keep the env file elsewhere
|
|
- pass `DEPLOY_ENV_FILE=/absolute/path/to/.env.production` in GitLab CI/CD variables
|
|
|
|
## GitLab CI/CD variables
|
|
|
|
Optional project variables:
|
|
|
|
- `DEPLOY_DIR` if you want a different deploy directory
|
|
- `APP_IMAGE_NAME` if you want a different Docker image name
|
|
- `HEALTHCHECK_URL` if the gateway health URL differs
|
|
- `DEPLOY_ENV_FILE` if `.env.production` should be copied from another location
|
|
|
|
## First deployment
|
|
|
|
1. Register the runner.
|
|
2. Add the production env file.
|
|
3. Push this configuration to the `main` branch.
|
|
4. Confirm the pipeline completes successfully.
|
|
5. Verify the container:
|
|
|
|
```bash
|
|
docker ps --filter name=call-center-app
|
|
```
|