Deploying from a self-managed GitLab instance

DDEV logo and GitLab logo

As developers and DevOps nerds, we are all about finding repeatable, automatable workflows, creating checklists, and standardizing processes so that everyone can do their best work unencumbered. One way to accomplish some of that, especially for a team, is to get set up with a self-hosted GitLab instance. But it can be challenging to connect and integrate that beautiful workspace with external tools and environments in a way that just flows and doesn’t require extra context switching. We explored one way to directly connect self-managed GitLab with a production environment using a simple setup so you can keep working and start deploying.

All customized and nowhere to go

Setting up a customized instance of GitLab can be key to centralizing team work and making sure that code is stored in a safe and private location. A self-managed GitLab instance can fulfill customer expectations for privacy and professionalism when deployed on-premises or in your preferred cloud. The ability to manage users, logs, and much more also makes self-managed GitLab practical for growing teams and projects. GitLab features strong support for Agile project management, ensuring that work is broken down, organized, and tracked for the entire team. With development work streamlined and developers all working in one place you can be efficient, secure, and focused. 

As a digital agency, your team might need to keep work in very tightly defined pipelines as it moves forward. That means excellent project managers maintaining feature branches tied to epics and releases so chunks of work can be developed, tested and deployed in isolated environments. With all of that organization happening in GitLab, how can you connect the workflow all the way through to deployment for testing or production? 

When it comes to deploying a project, things can get sticky. In order to get the latest changes from a self-managed GitLab instance to the web host you might need to manually export and move code, leverage GitLab CI/CD, or employ another integration tool. The more steps there are in the process, the greater the chance for breakage, loss, and failure. Plus, even though all the code is in GitLab, you might have different build and deploy processes for each CMS, pointed to different hosting providers. Things get tangled and confused and the overhead of maintaining so many different pipelines eats time and requires significant expertise.

Deploy from a self-managed GitLab instance

The DDEV-Live platform features the ability to directly connect a self-managed GitLab instance to a remote environment on our infrastructure. You may already have set up DDEV for your local development environment with projects from your repositories. There are just a couple more steps to start deploying to your DDEV-Live environment from your self-managed GitLab instance.

Configure a personal access token on your GitLab account and pass the credentials to your DDEV-Live workspace via our CLI tool. Once that’s set up, you can run the ddev-live create site… command with a reference to any repository branch, tag or commit. If you’ve configured your personal access token with the API scope, changes to the Git revision you referenced in the ddev-live create site command will automatically be pushed to DDEV-Live. This can also be manually configured with webhooks per project or builds can be triggered by hand.

That means you can now work in DDEV-Local with a project you’ve checked out from your GitLab instance, push changes up to the repository, and see an automatic build happen immediately on DDEV-Live. Everything can be controlled through the ddev and ddev-live CLI tools, and also be scripted in your favorite CI/CD tool using your DDEV API token. 

Benefits of a flexible development workflow

If you have a workflow and tools that you’ve set up to best support your projects, the last thing you want is to be disrupted. Any additional tools or systems you implement should make your process easier, not more complex, and should fit your process, not force you into workflows that don’t make sense for your developers, stakeholders, and projects. Something technically flexible to support a variety of PHP-based projects, as well as being adaptable and scriptable to integrate with other tools and providers. The best tool is the one that works for you, not against you.

Now that you can connect just about any Git repo to DDEV-Live to deploy projects into the cloud, you can continue to save time on manual tasks and engineering effort in setting up CI/CD systems. For an agency with a self-managed GitLab instance you can work with the full DDEV platform while continuing to support the privacy, security and efficiency needs of your team and your clients. 

For senior developers, the benefits might include time savings in setting up CI/CD pipelines for automated tasks. Instead of exporting code, you can directly reference your code right where it lives, in Git. Continue working with, or move to, self-managed GitLab to support your customer and internal project lifecycle needs. For all developers, the benefits include the flexibility to use the Git provider you prefer (GitHub, GitLab, and more as we build out agnostic Git support) and logical, straightforward commands you’ll use to interact with DDEV via CLI, leading to saved time and resources and the freedom to use the tech you want.

What’s next?

The DDEV platform gives you the ability to continue using your existing, customized GitLab instance to manage all your work, but now with direct connections to deploy to DDEV-Live for any stage of your development workflow. With your API token and installable CLI, you can probably imagine a lot of possibilities for how to integrate DDEV into your current workflows.

For example, in addition to using DDEV in your CI/CD pipelines, you might also be in search of a way to spin up quick preview sites that can be shared. This functionality can support a really robust QA process with clients, where you can show work in progress that is only at the PR stage. Soon DDEV will include the ability to call up a fresh site on our platform based on changes in a PR you have created.

What does your workflow look like today? What would like it to look like in the future? Reach out and tell us what features you’d like to see when working from GitLab!

Share this post: