gitlab server with docker-compose

less than 1 minute read

Install gitlab with docker-compose

version: '3.6'
services:
  gitlab:
    image: gitlab/gitlab-ee:16.10.6-ee.0
    container_name: gitlab
    restart: always
    hostname: '192.168.1.15'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://192.168.1.15:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2424
    ports:
      - '8929:8929'
      - '443:443'
      - '2424:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    shm_size: '256m'

Head to http://192.168.1.15:8929 and login with username root and password from the output of following command:

docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

Clone a repo for test:

git clone ssh://git@192.168.1.15:2424/fudongbai/test-code.git

Use gitlab with cli

brew install glab
sudo snap install glab

Head to User Settings / Access Tokens page and add new token with at least api and write_repository:

glab config set -g host 192.168.1.15:8929
glab config set --host 192.168.1.15:8929 api_protocol http
glab auth login --hostname 192.168.1.15:8929 --stdin < token.txt

These options are written to $HOME/.config/glab-cli/config.yml

Create new repository

glab repo create reading-notes

List repositories

glab repo list
Showing 2 of 2 projects (Page 1 of 1)

fudongbai/btrace     ssh://git@192.168.1.15:2424/fudongbai/btrace.git
fudongbai/test-code  ssh://git@192.168.1.15:2424/fudongbai/test-code.git

Clone repository

glab repo clone test-code
glab project clone test-code
glab project clone fudongbai/test-code