This documentation provides a step-by-step guide on configuring the development environment for the GitLab project, particularly using the docker-compose.yml
file. This guide assumes that the environment is already set up and focuses solely on configuration options that developers can utilize for their local development.
Configuration via docker-compose.yml
The primary method to configure your GitLab development environment is through the docker-compose.yml
file. Below are detailed settings and configurations you can apply.
Pull the Latest GitLab Image
To ensure that you are working with the most up-to-date version of GitLab, specify the latest image tag in the docker-compose.yml
file:
app:
image: gitlab/gitlab-ce:latest
Customizing Service Parameters
Feel free to customize the various environment variables to suit your development needs. For example, you can set the following environment variable configurations:
app:
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.local'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
In this example:
external_url
defines the URL that GitLab should use for its web access.gitlab_shell_ssh_port
customizes the SSH port used by GitLab.
Configuring Ports
You may need to expose certain ports for accessing GitLab services. An example configuration might look like this:
app:
ports:
- '80:80' # HTTP
- '443:443' # HTTPS
- '2222:22' # SSH
This setup maps the default ports for HTTP, HTTPS, and SSH from the container to your local machine.
Volumes Configuration
For persistent data storage and to facilitate local development, configure volumes in docker-compose.yml
. This allows you to maintain data across container restarts:
app:
volumes:
- gitlab_data:/var/opt/gitlab
- gitlab logs:/var/log/gitlab
- gitlab_config:/etc/gitlab
In this configuration:
gitlab_data
is used to persist GitLab data.gitlab_logs
is for logs generated by GitLab.gitlab_config
stores the configuration files.
Example of a Complete docker-compose.yml
The following is an example of how the complete docker-compose.yml
file may look with the aforementioned configurations:
version: '3.8'
services:
app:
image: gitlab/gitlab-ce:latest
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.local'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
ports:
- '80:80'
- '443:443'
- '2222:22'
volumes:
- gitlab_data:/var/opt/gitlab
- gitlab_logs:/var/log/gitlab
- gitlab_config:/etc/gitlab
volumes:
gitlab_data:
gitlab_logs:
gitlab_config:
Starting the Development Environment
Once your docker-compose.yml
configuration is complete, you can start your GitLab development environment by running:
docker-compose up
This command initializes and runs your GitLab instance based on the specified configurations.
Conclusion
This documentation provided an in-depth overview of configuration options for setting up the GitLab development environment using docker-compose.yml
. Ensure to tailor the configurations to align with your specific development workflow while adhering to best practices.
For further details and more advanced configurations, refer to the official GitLab documentation.