Container Supported Development: Boost Developer Productivity
This article explores the concept of container supported development and how it can significantly increase developer productivity, even if your main application isn't containerized. We'll look at the advantages of using containers for setting up development and testing environments.
Why Use Containers During Development?
The primary question we address is: why should you use containers during development? What value do they bring? This article demonstrates the many ways containers can be used to enhance developer productivity, regardless of whether the main application is containerized.
A Sample Application Architecture
Consider a sample application, a catalog service, composed of various services. It stores data in a PostgreSQL database, images and blob storage (e.g., AWS S3), and retrieves inventory data from an external inventory service. It also publishes update events to Kafka for other services to consume.
Dependencies include:
- PostgreSQL Database
- Image/Blob Storage (AWS S3)
- External Inventory Service
- Kafka
Setting Up Development and Testing Environments: Two Options
How do you set up the development and testing environment for such an application? There are two main approaches:
Option 1: Connecting to Shared Staging Infrastructure
This involves connecting to shared staging infrastructure, such as a Dev environment. A Dev instance can interact with a real S3 bucket, a deployed remote inventory service, and more. However, this approach doesn't scale well as the team grows. It adds complexity and potential conflicts as developers compete for shared resources, especially in organizations that provision resources per developer.
Option 2: Local Development Environment with Containers
This option involves creating a local development environment where each developer runs the dependent services on their machine using containers. This is generally a better approach. Instead of relying on deployed cloud infrastructure, you can use local, containerized alternatives:
- MinIO or LocalStack: Instead of a real S3 bucket
- WireMock: To mock the external inventory service API
- Local Kafka and PostgreSQL instances
The advantage of using containers is the ease of adding additional services without worrying about configuration, installation, and setup. Developers can publish and consume test messages in the local Kafka cluster and visualize the database.
Container Supported Development Explained
This approach of using containers to assist the development environment is called container supported development. It's important to emphasize that the main application doesn't necessarily need to be containerized. It can run natively using your IDE (e.g., VS Code, IntelliJ) by simply pressing the play button.
Containers in Integration Testing
Containers can also be used during integration testing. When a developer pushes their code, containers can spin up the required resources. This eliminates the need for shared infrastructure and infrastructure management. The Testcontainers framework simplifies the integration of container lifecycle with the test lifecycle. Containers spin up when tests start and are automatically removed upon completion.
Benefits of Container Supported Development
Hopefully, you're now starting to see the value of container supporter development: easier setup, less dependency on shared resources, faster iteration, and reliable test environments.
Stay tuned for the next videos, which will dive into specific use cases and demonstrate the value they provide, along with a few extra nuggets along the way.