backbeat: add module sources
This commit is contained in:
115
Dockerfile
Normal file
115
Dockerfile
Normal file
@@ -0,0 +1,115 @@
|
||||
# Build stage
|
||||
FROM golang:1.22-alpine AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git ca-certificates
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build all services
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o pulse ./cmd/pulse
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o reverb ./cmd/reverb
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o agent-sim ./cmd/agent-sim
|
||||
|
||||
# Pulse service image
|
||||
FROM alpine:latest AS pulse
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 backbeat && \
|
||||
adduser -D -s /bin/sh -u 1001 -G backbeat backbeat
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy pulse binary from builder
|
||||
COPY --from=builder /app/pulse .
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /data && chown -R backbeat:backbeat /data
|
||||
|
||||
# Switch to non-root user
|
||||
USER backbeat
|
||||
|
||||
# Expose ports (8080 for HTTP, 9000 for Raft)
|
||||
EXPOSE 8080 9000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
|
||||
|
||||
# Default command
|
||||
ENTRYPOINT ["./pulse"]
|
||||
CMD ["-cluster", "chorus-production", \
|
||||
"-admin-port", "8080", \
|
||||
"-raft-bind", "0.0.0.0:9000", \
|
||||
"-data-dir", "/data"]
|
||||
|
||||
# Reverb service image
|
||||
FROM alpine:latest AS reverb
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 backbeat && \
|
||||
adduser -D -s /bin/sh -u 1001 -G backbeat backbeat
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy reverb binary from builder
|
||||
COPY --from=builder /app/reverb .
|
||||
|
||||
# Switch to non-root user
|
||||
USER backbeat
|
||||
|
||||
# Expose port (8080 for HTTP)
|
||||
EXPOSE 8080
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
|
||||
|
||||
# Default command
|
||||
ENTRYPOINT ["./reverb"]
|
||||
CMD ["-cluster", "chorus-production", \
|
||||
"-nats", "nats://nats:4222", \
|
||||
"-bar-length", "120", \
|
||||
"-log-level", "info"]
|
||||
|
||||
# Agent simulator image
|
||||
FROM alpine:latest AS agent-sim
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 backbeat && \
|
||||
adduser -D -s /bin/sh -u 1001 -G backbeat backbeat
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy agent-sim binary from builder
|
||||
COPY --from=builder /app/agent-sim .
|
||||
|
||||
# Switch to non-root user
|
||||
USER backbeat
|
||||
|
||||
# Default command
|
||||
ENTRYPOINT ["./agent-sim"]
|
||||
CMD ["-cluster", "chorus-production", \
|
||||
"-nats", "nats://nats:4222"]
|
||||
Reference in New Issue
Block a user