Skip to content

ThomasInfield/gitlab-docker

Repository files navigation

GitLab CE Docker Compose - Quickstart

Cleanup and Reset

If you need to start fresh or reset your GitLab installation:

./cleanup.sh

This script will:

  • Stop all GitLab containers
  • Remove all GitLab data
  • Remove all logs
  • Remove SSL certificates
  • Give you a clean slate to start over

Initial Setup

  1. Copy the example configuration file:

    cp config.env.example .env
  2. Edit your settings in .env

  3. Start everything with:

    chmod +x setup.sh
    ./setup.sh
  4. Important: The initial root password will be displayed after setup. You can also retrieve it manually within the first 24 hours using:

    docker exec gitlab-docker-gitlab-1 cat /etc/gitlab/initial_root_password

    Make sure to change this password immediately after your first login!

  5. Het setup script maakt automatisch een self-signed SSL-certificaat aan voor je GitLab-domein. Dit certificaat wordt gegenereerd met een Subject Alternative Name (SAN) voor zowel je GitLab domein als je Container Registry domein ($REGISTRY).

  6. Register the runner:

    1. Log in to GitLab as root user
    2. Go to Admin Area > Overview > Runners (or navigate to https://gitlab.example.com/admin/runners)
    3. Note down the registration token shown at the top of the page
    4. Edit register-runner.sh and update:
    5. Make the script executable and run it:
    chmod +x register-runner.sh
    ./register-runner.sh
    1. The runner should now appear in your GitLab Runners overview page
    2. Optional: Configure additional runner settings in the GitLab UI:
      • Tags
      • Run untagged jobs
      • Lock to project
      • Maximum timeout

    Note: The runner registration uses the same SSL certificate as GitLab. Make sure your SSL certificate is properly set up in the ./ssl directory before registering the runner.

  7. Add your Ansible code to a GitLab project and include .gitlab-ci.yml

  8. Add the following GitLab CI/CD variables:

    • SSH_PRIVATE_KEY (your private key)
    • KNOWN_HOSTS (optional)

Done! Your GitLab environment is ready to use.

Additional Information

  • The folders data/, logs/, ssl/, and config/ are used for persistent storage and configuration.
  • Only .gitkeep files and explicitly listed files are tracked in version control.
  • See .gitignore for details.
  • Note: Docker Compose automatically loads variables from a file named .env in the project root.

For detailed instructions on configuring CI/CD variables for SSH keys and other necessary settings, refer to the documentation provided in the project.

Starting

Start the environment with Docker Compose (example):

docker compose up

Test Your Runner

  1. Create a new project in GitLab
  2. Create a new file .gitlab-ci.yml with this content:
    test-job:
      script:
        - echo "My first job"
        - echo "Runner is working!"
        - echo "Current date is $(date)"
  3. Commit and push the file
  4. Go to your project's CI/CD > Pipelines to see the job running

You should see your job execute successfully with the output messages. If this works, your runner is correctly configured!

For a more complete test that uses Docker:

test-docker:
  image: alpine:latest
  script:
    - echo "Testing from Alpine container"
    - uname -a
    - cat /etc/os-release

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published