Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docker/Dockerfile.chrome
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ WORKDIR /home/runner
COPY --chown=runner:runner entrypoint-chrome.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Copy Prometheus metrics scripts (Phase 2: Prometheus Monitoring)
# TASK-014: Add metrics scripts to Chrome runner
COPY --chown=runner:runner metrics-server.sh /usr/local/bin/metrics-server.sh
COPY --chown=runner:runner metrics-collector.sh /usr/local/bin/metrics-collector.sh
RUN chmod +x /usr/local/bin/metrics-server.sh /usr/local/bin/metrics-collector.sh

# TASK-014: Expose Prometheus metrics port
EXPOSE 9091

HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD pgrep -f "Runner.Listener" > /dev/null || exit 1

Expand Down
9 changes: 9 additions & 0 deletions docker/Dockerfile.chrome-go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
# --- INSTALL GO ---
# Use BuildKit cache for Go download
# Go supports both amd64 and arm64 architectures
RUN --mount=type=cache,target=/tmp/downloads \

Check failure on line 154 in docker/Dockerfile.chrome-go

View workflow job for this annotation

GitHub Actions / Lint and Validate

SC2086 info: Double quote to prevent globbing and word splitting.
GO_VERSION="1.25.5" \
&& case ${TARGETARCH} in \
"amd64") GO_ARCH="amd64" ;; \
Expand Down Expand Up @@ -243,6 +243,15 @@
COPY --chown=runner:runner entrypoint-chrome.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Copy Prometheus metrics scripts (Phase 2: Prometheus Monitoring)
# TASK-015: Add metrics scripts to Chrome-Go runner
COPY --chown=runner:runner metrics-server.sh /usr/local/bin/metrics-server.sh
COPY --chown=runner:runner metrics-collector.sh /usr/local/bin/metrics-collector.sh
RUN chmod +x /usr/local/bin/metrics-server.sh /usr/local/bin/metrics-collector.sh

# TASK-015: Expose Prometheus metrics port
EXPOSE 9091

HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD pgrep -f "Runner.Listener" > /dev/null || exit 1

Expand Down
12 changes: 12 additions & 0 deletions docker/docker-compose.chrome-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ services:
image: ghcr.io/grammatonic/github-runner:chrome-go-latest
container_name: github-runner-chrome-go
restart: unless-stopped
# TASK-017: Expose metrics port on unique host port to avoid conflicts
ports:
- "9093:9091" # Prometheus metrics endpoint (host:container)
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
- GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
Expand All @@ -14,6 +17,10 @@ services:
- RUNNER_REPLACE_EXISTING=${RUNNER_REPLACE_EXISTING:-true}
- DISPLAY=${DISPLAY:-:99}
- CHROME_FLAGS=${CHROME_FLAGS:---headless --no-sandbox --disable-dev-shm-usage --disable-gpu}
# TASK-019: Prometheus metrics configuration
- RUNNER_TYPE=chrome-go
- METRICS_PORT=9091
- METRICS_UPDATE_INTERVAL=${METRICS_UPDATE_INTERVAL:-30}
# Go-specific environment variables
- GO_VERSION=${GO_VERSION:-1.25.4}
- GOPATH=${GOPATH:-/home/runner/go}
Expand Down Expand Up @@ -41,6 +48,8 @@ services:
- chrome-go-cache-pip:/home/runner/.runnercache/pip
- chrome-go-cache-go:/home/runner/go/pkg
- /dev/shm:/dev/shm
# TASK-017: Persist job log for metrics across restarts
- chrome-go-jobs-log:/tmp
# Drop all capabilities except those needed for Chrome and Docker socket
cap_drop:
- ALL
Expand Down Expand Up @@ -81,6 +90,9 @@ volumes:
driver: local
chrome-go-cache-go:
driver: local
# TASK-017: Volume for persistent job log
chrome-go-jobs-log:
driver: local

networks:
runner-network:
Expand Down
12 changes: 12 additions & 0 deletions docker/docker-compose.chrome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ services:
image: ghcr.io/grammatonic/github-runner:chrome-latest
container_name: github-runner-chrome
restart: unless-stopped
# TASK-016: Expose metrics port on unique host port to avoid conflicts
ports:
- "9092:9091" # Prometheus metrics endpoint (host:container)
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
- GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
Expand All @@ -16,13 +19,19 @@ services:
- RUNNER_REPLACE_EXISTING=${RUNNER_REPLACE_EXISTING:-true}
- DISPLAY=${DISPLAY:-:99}
- CHROME_FLAGS=${CHROME_FLAGS:---headless --no-sandbox --disable-dev-shm-usage --disable-gpu}
# TASK-018: Prometheus metrics configuration
- RUNNER_TYPE=chrome
- METRICS_PORT=9091
- METRICS_UPDATE_INTERVAL=${METRICS_UPDATE_INTERVAL:-30}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- chrome-cache:/home/runner/_work
- chrome-config:/home/runner/.config
- chrome-cache-npm:/home/runner/.runnercache/npm
- chrome-cache-pip:/home/runner/.runnercache/pip
- /dev/shm:/dev/shm
# TASK-016: Persist job log for metrics across restarts
- chrome-jobs-log:/tmp
# Drop all capabilities except those needed for Chrome and Docker socket
cap_drop:
- ALL
Expand Down Expand Up @@ -61,6 +70,9 @@ volumes:
driver: local
chrome-cache-pip:
driver: local
# TASK-016: Volume for persistent job log
chrome-jobs-log:
driver: local

networks:
runner-network:
Expand Down
57 changes: 56 additions & 1 deletion docker/entrypoint-chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,47 @@ GITHUB_HOST="${GITHUB_HOST:-github.com}" # For GitHub Enterprise
# Validate GitHub host
validate_hostname "$GITHUB_HOST" || exit 1

# --- METRICS SETUP (Phase 2: Prometheus Monitoring) ---
# Start metrics services BEFORE token validation to enable standalone testing
# TASK-013: Initialize job log
JOBS_LOG="${JOBS_LOG:-/tmp/jobs.log}"
echo "Initializing job log: ${JOBS_LOG}"
touch "${JOBS_LOG}"

# TASK-013: Start metrics collection services
METRICS_PORT="${METRICS_PORT:-9091}"
METRICS_FILE="${METRICS_FILE:-/tmp/runner_metrics.prom}"
RUNNER_TYPE="${RUNNER_TYPE:-chrome}"

echo "Starting Prometheus metrics services..."
echo " - Metrics endpoint: http://localhost:${METRICS_PORT}/metrics"
echo " - Runner type: ${RUNNER_TYPE}"

# Start metrics collector in background
if [ -f "/usr/local/bin/metrics-collector.sh" ]; then
RUNNER_NAME="${RUNNER_NAME}" \
RUNNER_TYPE="${RUNNER_TYPE}" \
METRICS_FILE="${METRICS_FILE}" \
JOBS_LOG="${JOBS_LOG}" \
UPDATE_INTERVAL="${METRICS_UPDATE_INTERVAL:-30}" \
/usr/local/bin/metrics-collector.sh &
COLLECTOR_PID=$!
echo "Metrics collector started (PID: ${COLLECTOR_PID})"
else
echo "Warning: metrics-collector.sh not found, metrics collection disabled"
fi

# Start metrics HTTP server in background
if [ -f "/usr/local/bin/metrics-server.sh" ]; then
METRICS_PORT="${METRICS_PORT}" \
METRICS_FILE="${METRICS_FILE}" \
/usr/local/bin/metrics-server.sh &
SERVER_PID=$!
echo "Metrics server started (PID: ${SERVER_PID})"
else
echo "Warning: metrics-server.sh not found, metrics endpoint disabled"
fi

# Change to the runner's directory
cd /actions-runner

Expand Down Expand Up @@ -87,7 +128,21 @@ echo "Configuring runner..."

# Function to clean up the runner on exit
cleanup() {
echo "Signal received, removing runner registration..."
echo "Signal received, shutting down..."

# Stop metrics services
if [ -n "${COLLECTOR_PID:-}" ]; then
echo "Stopping metrics collector (PID: ${COLLECTOR_PID})..."
kill -TERM "${COLLECTOR_PID}" 2>/dev/null || true
fi

if [ -n "${SERVER_PID:-}" ]; then
echo "Stopping metrics server (PID: ${SERVER_PID})..."
kill -TERM "${SERVER_PID}" 2>/dev/null || true
fi

# Remove runner registration
echo "Removing runner registration..."
./config.sh remove --token "${RUNNER_TOKEN}"
echo "Runner registration removed."
}
Expand Down
Loading
Loading