Skip to content

Commit c20d6ba

Browse files
Merge pull request #31 from joshrotenberg/feat/docker-hub-publish
feat: add Docker Hub publishing workflow
2 parents 9a99e6e + a300b9e commit c20d6ba

File tree

3 files changed

+166
-4
lines changed

3 files changed

+166
-4
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Docker Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'redisctl-v*'
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: docker.io
13+
IMAGE_NAME: joshrotenberg/redisctl
14+
15+
jobs:
16+
build-and-push:
17+
name: Build and Push Docker Image
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Log in to Docker Hub
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
password: ${{ secrets.DOCKERHUB_TOKEN }}
35+
36+
- name: Extract metadata
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
type=ref,event=branch
43+
type=semver,pattern={{version}},value=${{ github.ref_name }}
44+
type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }}
45+
type=semver,pattern={{major}},value=${{ github.ref_name }}
46+
type=sha,prefix=sha-
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
file: ./Dockerfile.publish
54+
platforms: linux/amd64,linux/arm64
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
build-args: |
61+
RUST_VERSION=1.89
62+
63+
- name: Update Docker Hub Description
64+
uses: peter-evans/dockerhub-description@v4
65+
with:
66+
username: ${{ secrets.DOCKERHUB_USERNAME }}
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}
68+
repository: ${{ env.IMAGE_NAME }}
69+
short-description: "Unified CLI for Redis Cloud and Enterprise management"
70+
readme-filepath: ./README.md

Dockerfile.publish

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Redis CLI Docker Image - Optimized for Docker Hub
2+
# Multi-platform build with minimal size
3+
4+
ARG RUST_VERSION=1.89
5+
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION} AS builder
6+
7+
# Install cross-compilation tools
8+
RUN apt-get update && apt-get install -y \
9+
gcc-aarch64-linux-gnu \
10+
gcc-x86-64-linux-gnu \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
WORKDIR /build
14+
15+
# Copy workspace files
16+
COPY Cargo.toml ./
17+
COPY crates/ ./crates/
18+
19+
# Set up for cross-compilation
20+
ARG TARGETPLATFORM
21+
RUN case "$TARGETPLATFORM" in \
22+
"linux/amd64") echo "x86_64-unknown-linux-gnu" > /target.txt ;; \
23+
"linux/arm64") echo "aarch64-unknown-linux-gnu" > /target.txt ;; \
24+
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
25+
esac
26+
27+
# Build for the target platform
28+
RUN export TARGET=$(cat /target.txt) && \
29+
rustup target add $TARGET && \
30+
cargo build --release --target $TARGET --bin redisctl && \
31+
cp target/$TARGET/release/redisctl /redisctl
32+
33+
# Runtime stage - distroless for minimal size and security
34+
FROM gcr.io/distroless/cc-debian12:nonroot
35+
36+
# Copy the binary
37+
COPY --from=builder /redisctl /usr/local/bin/redisctl
38+
39+
# Set environment variables
40+
ENV REDIS_ENTERPRISE_URL=""
41+
ENV REDIS_ENTERPRISE_USER=""
42+
ENV REDIS_ENTERPRISE_PASSWORD=""
43+
ENV REDIS_CLOUD_API_KEY=""
44+
ENV REDIS_CLOUD_SECRET_KEY=""
45+
46+
# Use the nonroot user
47+
USER nonroot
48+
49+
ENTRYPOINT ["redisctl"]
50+
CMD ["--help"]

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,58 @@ cargo build --release --features enterprise-only --bin redis-enterprise
8383
cargo build --release --bin redisctl
8484
```
8585

86-
### Using Docker (for Enterprise testing)
86+
### Using Docker Hub Image
87+
88+
The official Docker images are available on Docker Hub at [joshrotenberg/redisctl](https://hub.docker.com/r/joshrotenberg/redisctl):
89+
90+
#### Available Tags
91+
- `latest` - Latest stable release
92+
- `v0.1.0`, `v0.2.0`, etc. - Specific version tags
93+
- `main` - Latest development build from main branch
94+
95+
```bash
96+
# Pull the latest image
97+
docker pull joshrotenberg/redisctl:latest
98+
99+
# Or pull a specific version
100+
docker pull joshrotenberg/redisctl:v0.1.0
101+
102+
# Run a command directly
103+
docker run --rm joshrotenberg/redisctl:latest --help
104+
105+
# Use with environment variables for Redis Cloud
106+
docker run --rm \
107+
-e REDIS_CLOUD_API_KEY="your-key" \
108+
-e REDIS_CLOUD_API_SECRET="your-secret" \
109+
joshrotenberg/redisctl:latest cloud subscription list
110+
111+
# Use with environment variables for Redis Enterprise
112+
docker run --rm \
113+
-e REDIS_ENTERPRISE_URL="https://your-cluster:9443" \
114+
-e REDIS_ENTERPRISE_USER="admin@example.com" \
115+
-e REDIS_ENTERPRISE_PASSWORD="your-password" \
116+
-e REDIS_ENTERPRISE_INSECURE="true" \
117+
joshrotenberg/redisctl:latest enterprise cluster info
118+
119+
# Run interactively with a shell
120+
docker run -it --rm \
121+
-e REDIS_ENTERPRISE_URL="https://your-cluster:9443" \
122+
-e REDIS_ENTERPRISE_USER="admin@example.com" \
123+
-e REDIS_ENTERPRISE_PASSWORD="your-password" \
124+
--entrypoint /bin/sh \
125+
joshrotenberg/redisctl:latest
126+
```
127+
128+
### Local Development with Docker Compose
87129
```bash
88130
# Start Redis Enterprise cluster with initialization
89131
docker compose up -d
90132

91133
# Check cluster status
92-
docker compose logs init
134+
docker compose logs init-cluster
93135

94-
# Access interactive CLI
95-
docker compose run --rm cli
136+
# Watch logs
137+
docker compose logs -f
96138

97139
# Clean up
98140
docker compose down -v

0 commit comments

Comments
 (0)