Drupal cloud development using devcontainers
Hi there! What is the best way to improve Drupal development and encourage teamwork among development groups? This question is important for many developers, especially as remote teams and complex projects become more common. Setting up and maintaining traditional Drupal development environments can take a lot of time, often leading to problems and delays. In this article, your Drupal development company will look at how devcontainers can improve your Drupal cloud development process for the better.
Containerization with Docker
Imagine a delivery service that needs to pack things well. The goods should take up minimal space and be as compact and correct as possible. Then, the delivery service should deliver the goods to the specified address, providing the customer with confidence in speed, quality, and safety. So, Docker is the best delivery service.
With this secure and lightweight containerization platform, you can use source code to build, ship, and run web applications and sites. Create a Docker image to run in any environment, including Drupal. You will have a fully functional and multi-tasking container when you run this image.
Benefits of Docker Dev Containers for Drupal Development
With these Dev Containers, you can greatly simplify the tasks of Drupal development. This greatly simplifies the execution of basic tasks for system administrators and developers. This way, you optimize and speed up the execution of a large number of tasks:
- creating a new production environment;
- deploying copies of websites and applications;
- continuous integration process;
- quickly moving websites to other servers;
- updating a website with different Drupal versions;
- scaling;
- testing;
- debugging and creating websites;
- personalized infrastructure setup.
To start developing Drupal using Docker Dev Containers, you just need to coordinate the work of the components. Thanks to Docker, the level of interaction between developers who work in different environments is significantly improved. You can instantly switch between projects while using the same version of PHP. Docker can also provide excellent isolation from host operating systems.
Among other objective advantages of containers, it is worth highlighting easy setup, scalability, quick removal, and rebuilding. In addition, due to their lightness, containers will take up a minimum of space on hard drives.
Using Docker Hub's capabilities, you can find a huge number of useful images that are ideal for Drupal.
Container Setup and Web Development
In fact, container development has not existed for a long time. They first began to be used in 2019. Today, this method is considered very mature and effective. According to many developers, Dev Containers are multifunctional and powerful tools for consistent and productive development.
Containers are used to automate your web development environment. With their help, you can pre-define a pre-configured development environment. It will be integrated with your IDE. And here, in the context of using Drupal, it is worth mentioning VS Code.
To set up a working environment in some projects, you need to do incredible amounts of work and follow strict step-by-step instructions. This is the only way to efficiently manually install and configure a wide range of tools. However, using Dev Containers makes this task much easier. You only need to perform a few steps:
- install Docker;
- install VS Code;
- add the necessary extensions for containers;
- use a host system on your preferred OS;
- clone a web project;
- open it with VS Code;
- run it via Dev Container.
As a result, you create a container based on the configurations you used in your project. Once the work is completed, you will have a great working environment for comfortable and high-quality development that is completely ready for use.
Features of Dev Container Setup
Among the key advantages of using solutions such as Docker containers when working with Drupal is the ability to access all changes and settings across different machines, regardless of the OS used and other parameters. Dev Containers provide you with a reproducible environment that can be versioned and used in a team if necessary. If you make any changes to the configuration of your container, then other members of your team will be offered the opportunity to instantly reconfigure it. To do this, you just need to click the corresponding Rebuild button in the pop-up window.
One of the most important features of Dev Containers is that all projects are executed in separate, lightweight, and isolated environments. This greatly simplifies collaboration when you are developing several projects at the same time.
For the setup, you will need the .devcontainer/devcontainer.json file. You can easily find it directly at the root of the project. The screenshot below shows a simple example of the settings that you can use.
Dev Container and VS Code
Using the visual diagram, you can understand how the Dev Container works when using the VS Code solution. With VS Code, you can easily mount the container's source code and then run all the aspects of the project you need. It works like this:
When you launch the terminal in VS Code, a connection is made to the container. So you can run the software you use, depending on your Dev settings.
All the necessary VS Code extensions are installed directly in the Dev Container. What does this mean? When you run a test or use the VS Code interface debugger, it will use the tools you configured in the container.
When running web servers inside containers, the port remains available on your host system. For this, localhost is used. When creating a site or web application, you can connect the host system's web browser directly to the site you launched inside Dev.
As you can see, this opens up many possibilities and allows you to develop and debug projects in the most comfortable conditions.
Preparation and Application Features
To use Dev containers for Drupal development, you will need to complete several preparation steps:
- install the current version of DDEV;
- install or update Docker;
- use a new version of the browser (Chrome or Firefox);
- install the necessary VS Code extensions.
Afterward, you can proceed to the next step and use a comprehensive solution to implement the tasks. You need to:
- create a new project folder and go to the directory;
- clone the repository to the folder you created in the previous step;
- use ddev drowl-init, which will allow you to launch the environment using Drupal along with VS Code.
That's it, and now you are entirely ready to perform work on developing and debugging your web project. Using ddev describe, you can quickly check the current status and URL of the project. The ddev code will allow you to launch a pre-prepared VS Code development environment.
Be sure to pay attention to the fact that in VS Code, you need to open the "Extensions" section and use the @recommended command. This way, you can see all the extensions you need. Install them to start working conveniently and efficiently. As practice shows, the joint use of such a combination of tools is great for solving various issues and problems:
- local Drupal development;
- testing and evaluating a site from scratch;
- development and evaluation of themes and modules, etc.
For what purposes you will use this solution depends on the tasks and goals you have set.
After completing your work, you may need to delete the container and exclude the project from the list. To do this, simply use the simple ddev delete command. Also, do not forget to delete the folder with your project if necessary.
To Sum Up
Drupal has amazing functionality and is considered one of the best systems for developing websites and web applications. Container development using solutions such as Docker opens up even more prospects for you and offers a wide range of useful tools. At the same time, completing all the tasks will become even easier, faster, and more convenient for you. You'll experience improved consistency across teams, simplified setup and maintenance, and accelerated development cycles.
Ready to experience the benefits of devcontainers for your Drupal projects? Start exploring today and discover a new level of efficiency and productivity in your development journey.
Comments