DEV Community

ADITYA KESHARI
ADITYA KESHARI

Posted on

Simplest Way to Set Up the Drogon C++ Framework

Recently, I tried this C++ web framework, which claims to be very fast. They mention, “Drogon is multi-threaded. On a single core of a Ryzen 3700X, Drogon can process more than 150K HTTP requests per second,” which I find incredible.

You can visit the official Drogon documentation and follow the installation steps here: Drogon Installation Guide.

However, if you want to avoid the hassle of installing numerous packages and libraries, follow along. The only prerequisite is that Docker must be installed on your machine.

Here’s a quick breakdown of how you can set up a Drogon environment and start working with it.

In this blog, I’ll show you how to set up Drogon using Docker, and don’t worry — this setup will provide a seamless development experience. So, let’s get started!Part 1

Part 1
Step1: Pull the Drogon image from docker hub.
docker pull drogonframework/drogon

Step2: Start the container and run drogon_ctl
docker run -it --name drogon_dev drogonframework/drogon /bin/bash

Step3: Inside the container, create a Drogon project.
drogon_ctl create project test_project

Step4: Copy the project files from the container to the host.
In another terminal, copy the files from the container to your local machine (outside the container).

docker cp drogon_dev:/path/to/test_project /path/to/local/folder

Step5: Stop the container: Once you’ve copied the files, stop the container for the next step:

docker stop drogon_dev

Part 2 — Set Up a Docker Volume for Auto-sync

Now that you have the project outside the container, you can mount the directory on the host to the container. This way, any changes you make outside the container will be reflected inside it.

Step1: Run the container with a volume mount: Mount the local project directory into the container:
docker run -it --name drogon_dev \
-v /path/to/local/folder/test_project:/path/in/container/test_project \
drogonframework/drogon /bin/bash

Replace /path/to/local/folder/test_project with the actual path where you copied the project files, and /path/in/container/test_project with the container path (e.g., /root/test_project or any appropriate path inside the container).

Step2: Work inside the container: Inside the container, you can now build or run the Drogon project:

cd /path/in/container/test_project
mkdir build
cd build
cmake ..
make

Auto-reflection of Changes
Since the project directory is mounted as a volume, any changes you make in the project folder outside the container (on your host system) will be reflected inside the container instantly.

This setup allows you to use your preferred editor outside the container while the build and runtime environment remains inside Docker.

Let me know if you need help with any specific step!

Top comments (0)