Skip to content

Commit 05fa505

Browse files
mujingclaude
andcommitted
feat: add middleware client tools (MySQL, PostgreSQL, Redis, Docker, Kafka CLI)
Add commonly used database and middleware client tools for development convenience: - PostgreSQL client 17 (psql) - Docker CLI with buildx and compose plugins - MySQL client (default-mysql-client) - Redis CLI (redis-tools) - Kafka CLI 3.9.0 with symlinks for frequently used scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4e533f1 commit 05fa505

4 files changed

Lines changed: 58 additions & 3 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ jobs:
256256
test_tool "vim" "vim --version | head -1" || FAILED_TOOLS="$FAILED_TOOLS vim"
257257
test_tool "kubectl" "kubectl version --client --output=json" || FAILED_TOOLS="$FAILED_TOOLS kubectl"
258258
test_tool "yq" "yq --version" || FAILED_TOOLS="$FAILED_TOOLS yq"
259+
260+
# Database and Middleware clients
261+
test_tool "mysql" "mysql --version" || FAILED_TOOLS="$FAILED_TOOLS mysql"
262+
test_tool "psql" "psql --version" || FAILED_TOOLS="$FAILED_TOOLS psql"
263+
test_tool "redis-cli" "redis-cli --version" || FAILED_TOOLS="$FAILED_TOOLS redis-cli"
264+
test_tool "docker" "docker --version" || FAILED_TOOLS="$FAILED_TOOLS docker"
265+
test_tool "kafka-topics" "kafka-topics.sh --version" || FAILED_TOOLS="$FAILED_TOOLS kafka-topics"
259266
260267
if [ -n "$FAILED_TOOLS" ]; then
261268
echo "::error::The following tools are not accessible:$FAILED_TOOLS"

Dockerfile

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,57 @@ RUN /opt/rbenv/plugins/ruby-build/install.sh \
174174
# Configure gem mirror
175175
RUN echo "---\n:sources:\n - https://gems.ruby-china.com/" > /home/coder/.gemrc
176176

177-
# Layer 8: Directory structure and config files
177+
# Layer 8: Database and Middleware Clients
178+
179+
# PostgreSQL client (official PostgreSQL apt repository)
180+
RUN mkdir -p /etc/apt/keyrings \
181+
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/keyrings/postgresql-keyring.gpg \
182+
&& chmod 644 /etc/apt/keyrings/postgresql-keyring.gpg \
183+
&& echo "deb [signed-by=/etc/apt/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/postgresql.list \
184+
&& apt-get update \
185+
&& apt-get install -y --no-install-recommends postgresql-client-17 \
186+
&& rm -rf /var/lib/apt/lists/*
187+
188+
# Docker CLI (official Docker apt repository, client only)
189+
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
190+
&& chmod 644 /etc/apt/keyrings/docker.gpg \
191+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list \
192+
&& apt-get update \
193+
&& apt-get install -y --no-install-recommends docker-ce-cli docker-buildx-plugin docker-compose-plugin \
194+
&& rm -rf /var/lib/apt/lists/*
195+
196+
# MySQL and Redis clients (Debian standard packages)
197+
RUN apt-get update && apt-get install -y --no-install-recommends \
198+
default-mysql-client \
199+
redis-tools \
200+
&& rm -rf /var/lib/apt/lists/*
201+
202+
# Kafka CLI tools
203+
ENV KAFKA_VERSION=3.9.0
204+
ENV KAFKA_SCALA_VERSION=2.13
205+
ENV KAFKA_HOME=/opt/kafka
206+
207+
RUN curl -fsSL "https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz" -o /tmp/kafka.tgz \
208+
&& mkdir -p ${KAFKA_HOME} \
209+
&& tar -xzf /tmp/kafka.tgz -C ${KAFKA_HOME} --strip-components=1 \
210+
&& rm -f /tmp/kafka.tgz \
211+
&& chmod +x ${KAFKA_HOME}/bin/*
212+
213+
# Create symlinks for frequently used Kafka tools
214+
RUN ln -s ${KAFKA_HOME}/bin/kafka-topics.sh /usr/local/bin/kafka-topics \
215+
&& ln -s ${KAFKA_HOME}/bin/kafka-console-consumer.sh /usr/local/bin/kafka-console-consumer \
216+
&& ln -s ${KAFKA_HOME}/bin/kafka-console-producer.sh /usr/local/bin/kafka-console-producer \
217+
&& ln -s ${KAFKA_HOME}/bin/kafka-consumer-groups.sh /usr/local/bin/kafka-consumer-groups \
218+
&& ln -s ${KAFKA_HOME}/bin/kafka-configs.sh /usr/local/bin/kafka-configs \
219+
&& ln -s ${KAFKA_HOME}/bin/kafka-acls.sh /usr/local/bin/kafka-acls
220+
221+
# Layer 9: Directory structure and config files
178222
# Create system-wide PATH config (not affected by volume mounts on /home/coder)
179223
# This ensures tools are accessible in all shell types (login/non-login, interactive/non-interactive)
180224
RUN echo '#!/bin/sh\n\
181225
# Development tools PATH configuration\n\
182226
# Note: Symlinks in /usr/local/bin provide fallback, this is additional coverage\n\
183-
export PATH=/opt/go-tools/bin:/opt/rbenv/bin:/opt/rbenv/shims:/usr/local/go/bin:/home/coder/go/bin:/opt/temurin-21-jdk/bin:/opt/conda/bin:$PATH' > /etc/profile.d/dev-tools.sh \
227+
export PATH=/opt/kafka/bin:/opt/go-tools/bin:/opt/rbenv/bin:/opt/rbenv/shims:/usr/local/go/bin:/home/coder/go/bin:/opt/temurin-21-jdk/bin:/opt/conda/bin:$PATH' > /etc/profile.d/dev-tools.sh \
184228
&& chmod +x /etc/profile.d/dev-tools.sh
185229

186230
# Create config templates directory (for volume mount compatibility)
@@ -190,7 +234,7 @@ RUN mkdir -p /opt/dev-configs
190234
# bashrc append content template
191235
RUN echo '\n\
192236
# Restore Docker ENV PATH (VS Code terminal resets PATH)\n\
193-
export PATH=/opt/go-tools/bin:/opt/rbenv/bin:/opt/rbenv/shims:/opt/temurin-21-jdk/bin:/opt/conda/bin:/usr/local/go/bin:/home/coder/go/bin:$PATH\n\
237+
export PATH=/opt/kafka/bin:/opt/go-tools/bin:/opt/rbenv/bin:/opt/rbenv/shims:/opt/temurin-21-jdk/bin:/opt/conda/bin:/usr/local/go/bin:/home/coder/go/bin:$PATH\n\
194238
\n\
195239
# User-installed gem executables path\n\
196240
export RUBY_GEM_ABI=${RUBY_GEM_ABI:-4.0.0}\n\

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A comprehensive development environment Docker image based on code-server, pre-c
1010
- **User**: `coder` with passwordless sudo (su blocked)
1111
- **Languages**: Go, Python 3.13, Node.js, JDK 21, Ruby/Rails
1212
- **Tools**: git, curl, wget, vim, tmux, dnsutils (nslookup), yq, kubectl, gopls, delve, uv, conda, pnpm, yarn, Maven, claude-code
13+
- **Middleware Clients**: MySQL CLI, PostgreSQL CLI (psql), Redis CLI, Docker CLI, Kafka CLI
1314

1415
## Quick Start
1516

@@ -172,6 +173,7 @@ The following components are installed in system directories and remain availabl
172173
| Python/conda | `/opt/conda` | python, pip, conda |
173174
| JDK | `/opt/temurin-21-jdk` | java, javac, jar |
174175
| Maven | `/opt/apache-maven` | mvn |
176+
| Kafka | `/opt/kafka` | kafka-topics, kafka-console-consumer, kafka-console-producer |
175177

176178
## Installed Languages
177179

README.zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- **默认用户**: `coder`(免密 sudo,`su` 被禁用)
1111
- **语言环境**: Go、Python 3.13、Node.js、JDK 21、Ruby/Rails
1212
- **开发工具**: git、curl、wget、vim、tmux、dnsutils (nslookup)、yq、kubectl、gopls、delve、uv、conda、pnpm、yarn、Maven、claude-code
13+
- **中间件客户端**: MySQL CLI、PostgreSQL CLI (psql)、Redis CLI、Docker CLI、Kafka CLI
1314

1415
## 快速开始
1516

@@ -172,6 +173,7 @@ docker run -d \
172173
| Python/conda | `/opt/conda` | python, pip, conda |
173174
| JDK | `/opt/temurin-21-jdk` | java, javac, jar |
174175
| Maven | `/opt/apache-maven` | mvn |
176+
| Kafka | `/opt/kafka` | kafka-topics, kafka-console-consumer, kafka-console-producer |
175177

176178
## 内置语言
177179

0 commit comments

Comments
 (0)