-
Notifications
You must be signed in to change notification settings - Fork 1.1k
build: add dev container for local development #5292
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
base: v3.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Development container for ProxySQL | ||
| # Based on: https://github.com/ProxySQL/docker-images/blob/main/build-images/build-ubuntu24/Dockerfile | ||
|
|
||
| FROM ubuntu:24.04 | ||
| LABEL authors="Miro Stauder <miro@sysown.com>" | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| RUN apt update && \ | ||
| apt full-upgrade -y | ||
|
|
||
| # gcc & build tools | ||
| RUN apt install -y \ | ||
| make cmake automake bison flex \ | ||
| git wget \ | ||
| gcc g++ \ | ||
| libtool \ | ||
| gdb gdbserver \ | ||
| equivs \ | ||
| python3 \ | ||
| zstd \ | ||
| pkg-config \ | ||
| sudo | ||
|
|
||
| # proxysql build dependencies | ||
| RUN apt install -y \ | ||
| libssl-dev gnutls-dev libgnutls28-dev \ | ||
| libmysqlclient-dev \ | ||
| libunwind8 libunwind-dev \ | ||
| uuid-dev \ | ||
| libncurses-dev \ | ||
| libicu-dev \ | ||
| libevent-dev \ | ||
| libtirpc-dev | ||
|
|
||
| # debug images need valgrind | ||
| RUN apt install -y \ | ||
| valgrind | ||
|
|
||
| # mysql client for testing | ||
| RUN apt install -y \ | ||
| mariadb-client | ||
|
|
||
| # clean apt cache | ||
| RUN apt clean && \ | ||
| rm -rf /var/cache/apt/* && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # fetch needed include | ||
| RUN wget -q -O /usr/include/mysql/hash.h https://raw.githubusercontent.com/mysql/mysql-server/5.7/include/hash.h | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better reproducibility and to avoid potential issues if the |
||
|
|
||
| # configure git safe dir | ||
| RUN git config --global --add safe.directory '*' | ||
|
|
||
| ENV CC=gcc | ||
| ENV CXX=g++ | ||
|
|
||
| RUN ${CXX} --version | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "ProxySQL Development", | ||
| "dockerComposeFile": "docker-compose.yaml", | ||
| "service": "dev", | ||
| "workspaceFolder": "/proxysql", | ||
| "shutdownAction": "stopCompose", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "ms-vscode.cpptools", | ||
| "ms-vscode.cmake-tools" | ||
| ] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| services: | ||
| dev: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| volumes: | ||
| - ..:/proxysql:cached | ||
| working_dir: /proxysql | ||
| init: true | ||
| command: sleep infinity | ||
|
|
||
| mariadb: | ||
| image: mariadb:11.4 | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: root | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Example Docker Compose will automatically pick up this file. MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This follows the existing project convention - all docker-compose files under docker/ use hardcoded MYSQL_ROOT_PASSWORD: root for local dev/test environments. |
||
| MYSQL_DATABASE: testdb | ||
| ports: | ||
| - "3306:3306" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,31 @@ Reference issues: When fixing bugs or implementing requested features, mention t | |||||||||||||
|
|
||||||||||||||
| ## Development Setup | ||||||||||||||
|
|
||||||||||||||
| ProxySQL provides Docker build images for development. The required packages for building are listed in the Dockerfiles at: https://github.com/ProxySQL/docker-images/tree/main/build-images | ||||||||||||||
| ### Using Dev Container (Recommended) | ||||||||||||||
|
|
||||||||||||||
| The easiest way to set up a development environment is using the included [dev container](https://containers.dev/): | ||||||||||||||
|
|
||||||||||||||
| **With a compatible IDE:** | ||||||||||||||
|
|
||||||||||||||
| Many IDEs support dev containers natively or via extensions. Simply open the repository and follow your IDE's prompts to reopen in the container. | ||||||||||||||
|
|
||||||||||||||
| **With Docker Compose:** | ||||||||||||||
| ```bash | ||||||||||||||
| # Start the dev container and MariaDB | ||||||||||||||
| docker compose -f .devcontainer/docker-compose.yaml up -d | ||||||||||||||
|
|
||||||||||||||
| # Go into dev container shell | ||||||||||||||
| docker compose -f .devcontainer/docker-compose.yaml exec dev bash | ||||||||||||||
|
|
||||||||||||||
| # Build ProxySQL | ||||||||||||||
| make | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| The MariaDB service is available at hostname `mariadb` for testing. | ||||||||||||||
|
|
||||||||||||||
| ### Manual Setup | ||||||||||||||
|
|
||||||||||||||
| If you prefer to set up your environment manually, the required packages for building are listed in the Dockerfiles at: https://github.com/ProxySQL/docker-images/tree/main/build-images | ||||||||||||||
|
|
||||||||||||||
| For example, to see packages needed for Ubuntu 24.04, check: https://github.com/ProxySQL/docker-images/blob/main/build-images/build-ubuntu24/Dockerfile | ||||||||||||||
|
Comment on lines
+43
to
45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convert bare URL to markdown link for consistency. Line 43 uses a bare URL while line 45 uses proper markdown link syntax. Per markdownlint (MD034), bare URLs should be avoided. Suggested fix-If you prefer to set up your environment manually, the required packages for building are listed in the Dockerfiles at: https://github.com/ProxySQL/docker-images/tree/main/build-images
+If you prefer to set up your environment manually, the required packages for building are listed in the Dockerfiles at: [ProxySQL/docker-images/build-images](https://github.com/ProxySQL/docker-images/tree/main/build-images)📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)43-43: Bare URL used (MD034, no-bare-urls) 45-45: Bare URL used (MD034, no-bare-urls) 🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a valid style nitpick. However, the existing CONTRIBUTING.md (before our changes) already had bare URLs in this section - we just moved them under a new "Manual Setup" heading. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rophy, that's a fair point! Since these bare URLs pre-existed your changes and you're just reorganizing the content, it makes sense that you wouldn't want to mix style fixes with functional changes in this PR. If you'd like to address the markdownlint warnings, it could be done in a separate cleanup PR, but it's certainly not required for this dev container addition. |
||||||||||||||
|
|
||||||||||||||
|
|
@@ -100,4 +124,4 @@ By contributing to ProxySQL, you agree that your contributions will be licensed | |||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| Thank you for helping make ProxySQL better! | ||||||||||||||
| Thank you for helping make ProxySQL better! | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To optimize the Docker image size and build speed, it's a best practice to chain all
aptoperations into a singleRUNcommand. This avoids creating multiple intermediate layers. Combiningapt-get update,apt-get install, and the cleanup steps (apt-get clean,rm) in one layer ensures that the package cache is cleaned up in the same layer it was created, effectively reducing the final image size. I've also added--no-install-recommendswhich is a common practice to further reduce size.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Though the current version honors original Dockerfile mentioned in
CONTRIBUTING.md.I'll let proxysql team comment if we want to optimize the Dockerfile.