Skip to content

feat: support devcontainer #11765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

bzp2010
Copy link
Contributor

@bzp2010 bzp2010 commented Nov 21, 2024

Description

Add devcontainer support to the project, which is expected to cover Linux, Windows (WSL2), macOS OSs, and the amd64, arm64 CPU ISAs, i.e. the environments used by most developers.

Basically, the container provides an isolated environment from the host, the runtime and toolset required for APISIX development are built in the container build, they will be available out of the box and developers no longer need to build and install them on the host. Just start dev container, wait a few moments, and it's ready to go.

Significantly simplify the parts that may be unfamiliar to developers and just focus on writing Lua code and test cases.

In addition to this, etcd is ready, maintained by docker-compose, and accessible on the local loopback.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@bzp2010
Copy link
Contributor Author

bzp2010 commented Nov 21, 2024

I have tested this on Windows WSL2 + Docker Desktop and macOS + OrbStack, where macOS is an arm64 based m4 chip.
Developers don't need to make any individual adjustments to any of the above environments, they will automatically do the right thing. (e.g. Installs the arm64-based binaries)

However, I don't have a desktop system running Linux, which would require someone else to help test, but that should not be a problem.

@bzp2010
Copy link
Contributor Author

bzp2010 commented Nov 21, 2024

The error in the CI is not related to this PR, it also fails on other PRs, will investigate it later.

UPDATE

I have fixed the issue in #11769.

@bzp2010 bzp2010 force-pushed the bzp/feat-devcontainer branch from 5533908 to 44bc599 Compare November 21, 2024 12:43
@bzp2010 bzp2010 marked this pull request as ready for review November 22, 2024 04:48
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 22, 2024
@bzp2010 bzp2010 requested a review from SkyeYoung November 22, 2024 06:19
@SkyeYoung
Copy link
Member

🆒 I will help with testing using Manjaro KDE Plasma(amd64) + Docker Engine.

@SkyeYoung
Copy link
Member

SkyeYoung commented Nov 22, 2024

Tested in Manjaro KDE Plasma (amd64) + Docker Engine:

image image

But I encountered some problems during the test:

image image

Error Log

error.log

Copy link

github-actions bot commented Feb 6, 2025

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 6, 2025
@bzp2010 bzp2010 removed the stale label Mar 16, 2025
@bzp2010 bzp2010 requested a review from SkyeYoung March 17, 2025 04:40
@bzp2010
Copy link
Contributor Author

bzp2010 commented Mar 20, 2025

This PR has been renovated, where the tests can run correctly, except for a problem that needs to be solved by #12070.

@SkyeYoung
Copy link
Member

This PR has been renovated, where the tests can run correctly, except for a problem that needs to be solved by #12070.

Looks like #12070 has been merged.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 30, 2025
@bzp2010
Copy link
Contributor Author

bzp2010 commented Mar 30, 2025

Merging the master branch to fix #12070 doesn't seem to be successful, I'll rebase and force push.

image

@bzp2010 bzp2010 force-pushed the bzp/feat-devcontainer branch from cf3b2f4 to 183ad13 Compare March 30, 2025 14:40
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Mar 30, 2025
@SkyeYoung
Copy link
Member

SkyeYoung commented Mar 31, 2025

Still got some error logs: It seems that there will be many problems caused by personal environmental factors

CleanShot 2025-03-31 at 21 56 12@2x

🤔

Comment on lines 36 to 37
&& rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz && rm -rf /tmp/etcd-download-test \
&& rm -rf /tmp/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe u can use rm -rf dir1 dir2 ...

"service": "apisix",
"workspaceFolder": "/workspace",
"privileged": true,
"postCreateCommand": "bash -c 'cd /workspace && rm -rf test-nginx && git config --global --add safe.directory /workspace && git submodule update --init --recursive && git clone https://github.com/openresty/test-nginx.git --depth 1 && make deps'",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u can try sth like git clone --depth 1 --single-branch --branch main


:::

Wait some minutes, depending on the internet connection or computer performance, it may take from a few minutes to tens of minutes, you can click on the Progress Bar in the bottom right corner to view a live log where you will be able to check unusual stuck.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Wait some minutes, depending on the internet connection or computer performance, it may take from a few minutes to tens of minutes, you can click on the Progress Bar in the bottom right corner to view a live log where you will be able to check unusual stuck.
Wait some minutes, depending on the internet connection or computer performance, it may take from a few minutes to tens of minutes, you can click on the Progress Bar in the bottom right corner to view a live log where you will be able to check unusual stuck.
If you encounter any problems, you can search or ask questions in [GitHub Issues](https://github.com/apache/apisix/issues) or [GitHub Discussions](https://github.com/apache/apisix/discussions), and community members will respond as promptly as possible.

Comment on lines +102 to +105
make test

# or run a specify test case file
TEST_NGINX_BINARY=openresty FLUSH_ETCD=1 prove -Itest-nginx/lib -I. -r t/admin/api.t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
make test
# or run a specify test case file
TEST_NGINX_BINARY=openresty FLUSH_ETCD=1 prove -Itest-nginx/lib -I. -r t/admin/api.t
export TEST_NGINX_BINARY=openresty
# run all tests
make test
# or run a specify test case file
FLUSH_ETCD=1 prove -Itest-nginx/lib -I. -r t/admin/api.t

make test requires TEST_NGINX_BINARY.


It will be on your host, which is where you cloned the APISIX source code, and the container uses the volume to mount the code into the container. Containers contain only the runtime environment, not the source code, so no changes will be lost whether you close or delete the container.

And, the git is already installed in the container, so you can commit a change directly there.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
And, the git is already installed in the container, so you can commit a change directly there.
And, the `git` is already installed in the container, so you can commit a change directly there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

2 participants