apache-rocketmq
SUCCESS
13m 14s
History Source
SummaryIterations1Transcript7Dockerfile
Dockerfile51 lines · 1532 chars
# Multi-stage Dockerfile to build Apache RocketMQ from source and provide a runnable runtime
# Stage 1: builder - install Java and Bazelisk to build the repository from source
FROM eclipse-temurin:8-jdk AS builder

# Essential utilities
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
        curl \
        ca-certificates \
        git \
        unzip \
        bash \
        build-essential \
        python3 \
        python3-pip \
    && rm -rf /var/lib/apt/lists/*

# Install Bazelisk (a Bazel wrapper) and expose `bazel` command
RUN curl -Lo /usr/local/bin/bazelisk \
        https://github.com/bazelbuild/bazelisk/releases/download/v1.12.0/bazelisk-linux-amd64 \
    && chmod +x /usr/local/bin/bazelisk \
    && ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel

# Set working directory and copy source
WORKDIR /workspace
COPY . /workspace

# Verify Bazel version (will download Bazel as needed by bazelisk)
RUN bazel --version || true

# Build the repository from source (may take a while, depending on network and cache)
RUN bazel build //...

# Stage 2: runtime
FROM eclipse-temurin:8-jre

# Optional: keep the same user context
RUN useradd -m rocketmq
USER rocketmq

WORKDIR /workspace

# Copy build outputs (bazel-bin and related) from builder stage if present
COPY --from=builder /workspace /workspace

# Expose common RocketMQ ports (NameServer and Broker) for convenience
EXPOSE 9876 10911

# Default to an interactive shell; user can start the broker/name server manually
CMD ["bash"]