Overview

This documentation provides a step-by-step guide on using Docker within the GitLab Community Edition (CE) development environment. The focus will be on how Docker is utilized for the development process, ensuring that you can effectively set up and manage your development workflow with the provided containerization technologies.

Prerequisites

Before diving into the setup, ensure you have the following installed:

  • Docker: Version 20.10.0 or higher
  • Docker Compose: Version 1.27.0 or higher

Make sure you have cloned the GitLab CE repository to your local machine:

git clone https://gitlab.com/gitlab-org/gitlab-ce.git
cd gitlab-ce

Docker Setup for Development

1. Docker Configuration Files

The primary configuration for using Docker in the GitLab CE development environment resides in the docker directory of the cloned repository. Key files include:

  • Dockerfile: Defines the base image and exposes necessary ports.
  • docker-compose.yml: Manages multi-container applications.

Example: Dockerfile

Here is a basic example of the Dockerfile found within the docker directory:

FROM ruby:2.7

# Install dependencies
RUN apt-get update && apt-get install -y \
  build-essential \
  libcurl4-openssl-dev \
  libpq-dev \
  libsqlite3-dev \
  && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /opt/gitlab

# Copy the Gemfile and install gems
COPY Gemfile Gemfile.lock ./
RUN bundle install --jobs=4 --retry=3

# Add the application code
COPY . .

# Expose necessary ports
EXPOSE 3000 8080

Example: docker-compose.yml

Below is a simplified snippet of the docker-compose.yml file used for orchestrating services:

version: '3'

services:
  web:
    build: .
    command: bundle exec rails server -b 0.0.0.0
    volumes:
      - .:/opt/gitlab
    ports:
      - "3000:3000"
    depends_on:
      - db

  db:
    image: postgres:12
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

2. Building the Docker Image

To build the Docker image for the development environment:

docker-compose build

3. Running the Development Environment

To start the development environment, use the following command:

docker-compose up

This command will initiate the services defined in docker-compose.yml. You should see logs corresponding to the services you’ve configured, including the web and database services.

4. Accessing the Application

Once the services are up and running, access the application in your browser at http://localhost:3000. This allows you to interact with GitLab CE in a fully operational development environment.

5. Running Migrations

To ensure that your database is in sync with the latest schema, run the migrations:

docker-compose run web rake db:migrate

6. Stopping the Development Environment

To stop the currently running services, execute:

docker-compose down

This command will gracefully shut down all the services and remove containers, networks, and volumes defined in docker-compose.yml.

Debugging and Logs

For debugging, you can view the logs generated by the running services. To see the logs of a specific service:

docker-compose logs web

Conclusion

Utilizing Docker in the GitLab CE development environment simplifies the setup and management of dependencies, allowing developers to start contributing quickly. For further details, always refer to the latest GitLab documentation.

References

Source of the information derived from the internal GitLab CE documentation.

Docker configuration assists in maintaining a consistent development environment, allowing developers to focus on contributing effectively.
https://docs.gitlab.com/ee/ 
Utilization of Docker enhances productivity by managing application dependencies efficiently.