Automate source deployment on main

This commit is contained in:
Your Name
2026-04-04 03:10:08 +05:00
parent dcddd12c56
commit 6cebd8216c
8 changed files with 320 additions and 41 deletions
+80
View File
@@ -0,0 +1,80 @@
# 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
```
+4
View File
@@ -7,6 +7,10 @@ This project is prepared for a GitLab-first delivery flow:
3. GitLab CI builds and pushes container images to GitLab Container Registry.
4. The server only receives the deployment bundle and pulls images from the registry.
For a same-host shell-runner flow that rebuilds `call-center-app` directly on push to `main`, see:
- `docs/runbooks/gitlab-cicd.md`
## Files used
- `.gitlab-ci.yml`