This repository sets up a self-contained GitLab environment using Docker Compose. It includes:
- ✅ GitLab CE Server
- 🏃 GitLab Runner (Docker executor with DinD)
- 📦 GitLab Container Registry
- 🧪 Sample
.gitlab-ci.ymlpipeline with Python build, test, Docker image stages and deployment
local-gitlab-setup/
├── gitlab-setup/
│ ├── docker-compose.yml
│ └── register-runner.sh
├── .gitlab-ci.yml
├── src/
│ └── main.py
├── test.py
└── README.md
git clone https://github.com/mohammad-majoony/local-gitlab-setup.git
cd local-gitlab-setupdocker compose up -dGitLab will be available at: http://localhost:80
Edit register-runner.sh if needed (e.g. update token), then run:
chmod +x register-runner.sh
./register-runner.shThe runner will be registered using Docker executor, connected to the internal Docker network.
The .gitlab-ci.yml file defines the following stages:
- Creates a Python virtual environment and installs dependencies.
- Uses
python:3.9-alpine.
- Runs
test.pyusing the virtual environment created in the build stage.
- Builds a Docker image and pushes it to GitLab Container Registry (
gitlab-server:5001). - Uses Docker-in-Docker (
docker:dind).
- Pulls the Docker image from GitLab Container Registry (gitlab-server:5001).
- Run the Docker compose file
These are for local development only — change them in production!
- Email / Username:
admin@gmail.com - Password:
Password@Ramona
Your registry is available at:
http://gitlab-server:5001
You can login using:
docker login -u <your-username> -p <your-password> http://gitlab-server:5001And push images like:
docker tag my-image gitlab-server:5001/namespace/project:latest
docker push gitlab-server:5001/namespace/project:latestTo stop and remove all containers, networks, and volumes:
docker compose down -v- Uses a custom Docker network (
gitlab-in-docker) to allow services to communicate. - DIND runner allows Docker builds within CI pipelines.
- The registry is enabled and runs alongside GitLab on port
5001.