Overview
This document provides a detailed step-by-step guide for deploying the GitLab Community Edition (CE) to a production environment. The deployment process utilizes Docker and its associated tooling. Before proceeding, ensure that the necessary infrastructure and permissions are in place.
Preparation
Requirements
Ensure that the following tools are installed before you begin:
- Docker: This will be used to manage containers.
- Docker Compose: This tool is used to define and run multi-container Docker applications.
Clone the Repository
Clone the GitLab CE repository to your local machine.
git clone https://gitlab.com/gitlab-org/gitlab-ce.git
cd gitlab-ce
Configuration
Docker Compose File
The Docker configuration is primarily managed through the docker-compose.yml
file. Open this file to review and adjust the necessary configurations.
app:
image: gitlab/gitlab-ce:latest
This snippet specifies that the GitLab CE application container will use the latest image from the GitLab registry. Ensure your image is appropriately tagged and pulled before deploying.
Building the Docker Image
Custom Dockerfile Configuration
The Docker image can be customized by editing the Dockerfile
. Below is the relevant configuration for building a production-ready image.
ARG BUILD_OS=debian
ARG CHROME_VERSION=123
ARG DOCKER_VERSION=24.0.5
ARG GIT_VERSION=2.45
ARG RUBY_VERSION=3.2.4
FROM registry.gitlab.com/gitlab-org/gitlab-build-images/${BUILD_OS}-${OS_VERSION}-ruby-${RUBY_VERSION}:git-${GIT_VERSION}
RUN apt-get update \
&& apt-get install -y xvfb unzip google-cloud-sdk-gke-gcloud-auth-plugin \
&& apt-get -yq autoremove \
&& apt-get clean -yqq \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /home/gitlab/qa
COPY qa/Gemfile* /home/gitlab/qa/
RUN bundle install --retry=3
Running the Application
Start Docker Compose
Once configuration and customization are complete, you can start the application using Docker Compose. This will spin up all necessary services defined in your docker-compose.yml
file.
docker-compose up -d
The -d
flag runs containers in detached mode, allowing them to run in the background.
Accessing GitLab
After the containers have started, access your GitLab instance by navigating to the suitable URL (commonly http://localhost:8080
or the relevant domain).
Post-Deployment Configuration
Environment Variables
It might be necessary to configure additional environment variables for production use. You can set these in your Docker Compose file under the app
service. For example:
environment:
GITLAB_OMNIAUTH_PROVIDERS: '[]'
GITLAB_HTTPS: 'true'
GITLAB_HOST: 'gitlab.example.com'
Persistence and Backup
Persistent storage for GitLab data is crucial to ensure that state is maintained across deployments. It is advisable to mount volumes to preserve your GitLab configurations, repositories, and backups.
volumes:
gitlab-data:
driver: local
Troubleshooting
In case of issues during deployment, logs can be viewed using:
docker-compose logs -f
This command allows you to follow log output for specific services, which aids in diagnosing potential issues.
Conclusion
Following this guide, you should be able to deploy GitLab CE in a production environment successfully. Ensure to monitor the deployment and make necessary adjustments to configurations based on your specific infrastructure and requirements.
This documentation is referenced from the source files found in the GitLab CE repository. Adjust configurations to suit unique deployment needs.