How to Set Up a Developer Environment for Apache AGE using Docker
Tags: apacheage, postgres, docker
Published: 2023-07-28 13:16:47

This is a guide on setting up your developer environment for Apache AGE using Docker on WSL. Docker simplifies your workflow and enhances your productivity. It allows you to create, deploy, and run applications by using containers. It will be helpful if you need to work on many versions of a software, like postgres.

Let's go into the steps!

## Pre-requisites

This short tutorial was built using WSL2, with integrated docker.

## Step 1: Create AGE Fork and Clone PostgreSQL

On your host OS, clone your own fork of Apache AGE and clone postgres in two side-by-side folders.

## Step 2: Get Base Image and Install Build Essentials

I like using the image debian:stable-slim, as it is very lightweight. You can get it by pulling from docker hub:

```
docker run debian:stable-slim
```

Start by running a Docker container with the command:

```bash
docker run --name <new_image_name> -h <new_tag> -e LANG=C.UTF-8 -it debian:stable-slim /bin/bash -l
```

Next, we need to update our software packages and install the essential ones. Run these commands on the terminal inside the container, which just opened:

```bash
apt update && apt upgrade --yes && apt install sudo locales --yes
dpkg-reconfigure tzdata
```

Now, we'll create a new user and give them sudo permissions. Replace `<your_username>` with your chosen username:

```bash
adduser <your_username>
echo "<your_username> ALL=PASSWD: ALL" > /etc/sudoers.d/<your_username>
su - <your_username>
```

Lastly, we need to install some necessary tools. Run:

```bash
sudo apt install htop git build-essential cmake libreadline-dev zlib1g-dev flex bison libicu-dev pkgconf vim --yes
```

## Step 3: Clone Image and Delete the Old One

To create a new Docker image from changes made to the current container, run:

```bash
docker image ls
docker commit debian:stable-slim <new_image_name:new_tag>
```

Then, you can remove the old container using:

```bash
docker rm debian:stable-slim
```

The newly created image will serve as your base to create other containers with different versions of postgres.

## Step 4: Run the Container

Finally, we can run our new container. Make sure to replace the path placeholders with the actual source and destination paths for AGE:

```bash
docker run \
	--name <new_container_name> -h <new_host_name> \
	-v path/to/age/source:path/to/age/destination/inside/container \
	-it <new_image_name>:<hostname> /bin/bash
```

Congrats! You've now set up your developer environment for Apache AGE using Docker. This environment will be isolated from the other parts of your system, which helps to keep your workstation clean and organized.

Keep in mind that Docker is an extensive platform, and there's a lot more to learn. However, understanding these basics will significantly improve your workflow as a developer. 

___

I make these posts in order to guide people into the development of a new technology. If you find anything incorrect, I urge you to comment below so I can fix it. Thanks!

___

Check Apache AGE: https://age.apache.org/.

Overview — Apache AGE master documentation: https://age.apache.org/age-manual/master/intro/overview.html.

GitHub - apache/age: https://github.com/apache/age