This repository contains configuration files to set up a comprehensive development environment using Devbox. Devbox is a powerful tool that allows developers to create reproducible and isolated development environments.
The setup includes the following main components:
- Node.js with Canvas support
- Elixir
- PostgreSQL with TimescaleDB extension
- Redis
- Apache Kafka and Zookeeper
The devbox.json file specifies the packages to be installed in the development environment. It includes:
- Node.js (version 18) with necessary libraries for canvas support (Pango, libpng, Cairo, etc.)
- Elixir (version 1.15.7)
- PostgreSQL with TimescaleDB
- Redis (version 7.2.5)
- Apache Kafka (version 2.13-3.8.0) and Zookeeper (version 3.9.2)
This file ensures that all developers working on the project have the same versions of these tools and libraries, reducing "it works on my machine" issues.
The process-compose.yaml file is used to run services locally without containers. It defines the following processes:
- PostgreSQL: Initializes and starts a PostgreSQL server with TimescaleDB extension.
- Redis: Starts a Redis server.
- Zookeeper: Manages the Zookeeper service for Kafka.
- Kafka: Starts the Kafka broker, depending on Zookeeper.
This file allows developers to easily start all necessary services for local development with a single command.
- Install Devbox by following the instructions on the official Devbox website.
- Clone this repository.
- Run
devbox shellto enter the development environment. - Use
devbox services upto start all the services defined inprocess-compose.yamlin the management mode.
Now you have a fully configured development environment with all necessary services running locally!
To interact with PostgreSQL:
- Create DB
createdb --host=localhost --port=5432 --username=postgres --password postgres
- Add timescaledb extension
psql --username=postgres --host=localhost --port=5432 --dbname=postgres -c 'CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;'
To interact with Redis using the Redis CLI:
-
Open a new terminal window.
-
Enter the Devbox shell by running
devbox shell. -
Use the Redis CLI command to connect to your Redis server:
redis-cli -
You can now run Redis commands directly. For example:
SET mykey "Hello" GET mykey -
To exit the Redis CLI, type
exitor press Ctrl+C.
To interact with Kafka using Kafkactl:
-
Open a new terminal window.
-
Enter the Devbox shell by running
devbox shell. -
Use Kafkactl commands to interact with your Kafka cluster. Here are some common operations:
-
List topics:
kafkactl get topics -
Create a new topic:
kafkactl create topic my-topic --partitions 3 --replication-factor 1 -
Produce messages to a topic:
kafkactl produce my-topic --value=test -
Consume messages from a topic:
kafkactl consume my-topic --from-beginning -
Describe a topic:
kafkactl describe topic my-topic
-
Remember to replace my-topic with your actual topic name when using these commands.
For more advanced usage and options, refer to the Kafkactl documentation.
- Consistency: Ensures all developers use the same versions of tools and libraries.
- Isolation: Keeps project dependencies separate from your system-wide installations.
- Ease of Use: Simplifies the process of setting up and running multiple services.
- Reproducibility: Makes it easy to recreate the development environment on any machine.
Happy coding!
