Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
38.89k stars 4.78k forks source link

Dev container required fixing for initial setup #11422

Closed ItsKaleb closed 11 months ago

ItsKaleb commented 1 year ago

Is there an existing issue for this?

Kong version ($ kong version)

3.5

Current Behavior

When I clone the master branch and attempt to start a dev container in VS Code, Kong fails to build with errors related to missing expat.h and curl.

Once resolved, further errors are encountered when attempting to run make test where a GitHub token is required to clone admin gui repo.

Expected Behavior

Expected behaviour is that the dev container should be able to build successfully on a fresh clone and tests should be able to run.

Steps To Reproduce

From a fresh environment:

Attempt to start the Dev Container through VS Code

Anything else?

This is my first dive into dev containers, so I am not confident in my work around. If it does assist though, I was able to resolve the problem by making the following changes to /.devcontainer/Dockerfile

--- FROM kong/kong:3.0.0-ubuntu
+++ FROM kong/kong:3.4.0-ubuntu

USER root

RUN apt-get update

RUN apt-get install -y \
        build-essential \
        unzip \
        git \
        m4 \
        libyaml-dev

+++ RUN apt-get install -y \
+++         libexpat1-dev \
+++         curl
+++
+++ ENV GH_TOKEN "a github token with readonly permission for public repos"
ItsKaleb commented 1 year ago

I've also found that, while I'm able to get the tests running now, they are incredibly slow. Plus there's no output, so I can't tell what they're doing or why they are taking so long. Running make test-plugins didn't finish after running for 3 hours.

hanshuebner commented 1 year ago

The devcontainer configuration has not been maintained in a while and is likely no longer working. The supported way to build Kong for testing bundled plugins is to follow the build instructions. From within the virtual environment built by bazel, it is possible to run the tests using the bin/busted script that is included with the source code.

ItsKaleb commented 1 year ago

Hmm, ok. Would've been nice to have a slightly more turn-key option, but will give it a go on a Virtual Box VM. Thanks for the input, @hanshuebner.

... Technically speaking, shouldn't it be possible to set up a dev container using something like a base Ubuntu image, and have it run the steps from those build instructions as part of the Dockerfile? I might also poke around with that and see if I can get the container working again too. Might be a nice to have?

hanshuebner commented 1 year ago

Having a turn-key developer image would be nice, and updating the dev container Dockerfile to use an Ubuntu base image and then run a build would make sense. If you get stuck at anything, let us know. I'll also gladly test and review a PR with updates.

ItsKaleb commented 1 year ago

Just as an update, I've so far got the dev container configured with the specified dev dependencies, and it's able to run make dev to build Kong. I can also run make test, but some of the tests fail - this is almost certainly due to the fact that I've not quite got the built version of Kong running in the container yet.

The existing tools for running a locally built Kong assume that you are on a VM or local machine, and attempt to start the required containers - I still need to translate this into starting the Kong instance inside the container and leveraging the supporting containers (like postgres DB) that are started as part of the .devcontainer/docker-compose.yml file.

ItsKaleb commented 1 year ago

I've spent another couple of hours on this today. While I am getting Kong to start up in the dev container, any calls made to it are just hanging at the moment. I'm kinda skeptical that it's to do with the Postgres container, as a nc to that container also hangs. Unfortunately, I've not found any logs to indicate what's going on though. Mainly, a local curl to 0.0.0.0:8001/status just hangs.

What is slightly more promising is the output from the Postgres container - I can see evidence that the PG initialisation is working and the kong and kong-testing DBs are being set up. So hopefully once I get over this alleged connectivity issue things will fall into place.

StarlightIbuki commented 11 months ago

Dear contributor, We're closing this issue as there hasn't been any update to it for a long time. If the issue is still relevant in the latest version, please feel free to reopen it. We're more than happy to revisit it again. Your contribution is greatly appreciated! Please have a look at our pledge to the community for more information. Sincerely, Kong Gateway Team