Skip to main content

Gitlab docker

·218 words·2 mins
Author
Ian Blockmans
I make things and also virtual things

Docker compose file
#

Use a version for the docker image to avoid a too large version jump when updating. This file also includes a runner example.

services:
  gitlab:
    image: gitlab/gitlab-ce:18.0.3-ce.0
    restart: unless-stopped
    ports:
      - 38580:38580
      - 38543:38543
      - 38522:22
    volumes:
      - /nfs/configs/gitlab/config:/etc/gitlab
      - /nfs/configs/gitlab/logs:/var/log/gitlab
      - /nfs/configs/gitlab/data:/var/opt/gitlab
    memswap_limit: 6G
    deploy:
      resources:
        limits:
          memory: 6G
    labels:
      loki: "false"
      traefik.enable: "true"
      traefik.http.routers.gitlab80.entrypoints: web
      traefik.http.routers.gitlab80.rule: Host(`gitlab.ian.lan`)
      traefik.http.routers.gitlab80.tls: "false"
      traefik.http.routers.gitlab80.middlewares: gitlab-https
      traefik.http.middlewares.gitlab-https.redirectscheme.scheme: https
      traefik.http.routers.gitlab.entrypoints: websecure
      traefik.http.routers.gitlab.rule: Host(`gitlab.ian.lan`)
      traefik.http.routers.gitlab.tls: "true"
      traefik.http.routers.gitlab80r.entrypoints: web
      traefik.http.routers.gitlab80r.rule: Host(`gitlab.ianb.be`)
      traefik.http.routers.gitlab80r.tls: "false"
      traefik.http.routers.gitlab80r.middlewares: gitlab-https
      traefik.http.routers.gitlabr.entrypoints: websecure
      traefik.http.routers.gitlabr.rule: Host(`gitlab.ianb.be`)
      traefik.http.routers.gitlabr.tls: "true"
      traefik.http.routers.gitlabr.tls.certresolver: production
      traefik.http.services.gitlab.loadbalancer.server.port: "38580"
  gitlab-runner-nas:
    image: gitlab/gitlab-runner:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /nfs/configs/gitlab/testing-runner/config:/etc/gitlab-runner
  gitlab-runner-x86-rust:
    image: gitlab/gitlab-runner:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /nfs/configs/gitlab/x86-rust-runner/config:/etc/gitlab-runner
networks: {}

proxy setup
#

Set nginx port to 80 and disable nginx tls in gitlab config file. docker forwards 80 to 38580 and Traefik reverse proxy to https://gitlab.ian.lan/.

import
#

Import from github needs to be enabled in the general settings in the admin panel.

can’t push
#

/var/opt/gitlab/git-data/repositories contents should have ‘git’ as user if not you can not push. Or set owner of /nfs/configs/gitlab/data/git-data/repositories and all its contents to 998 user and group (chown git:git).

This issue has to do with nfs-based filesystems (source). Gitlab claims it is out of there control so no fix is coming.

Command for new repo fix:

chown -R 998:998 /nfs/configs/gitlab/data/git-data/repositories/