Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
135 lines (112 loc) · 4.3 KB
/
Copy pathDockerfile
File metadata and controls
135 lines (112 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# HotPlex Worker Gateway - Production Dockerfile
#
# Multi-stage build for production deployment
# Best practices:
# - Build stage with full Go toolchain
# - Runtime stage with minimal Alpine + necessary runtimes (Node, Python)
# - Non-root user
# - Health check
# - Proper signal handling
# - Security hardening
#
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1: Build
# ─────────────────────────────────────────────────────────────────────────────
FROM golang:1.26-alpine AS builder
# Build arguments for version injection
ARG GIT_SHA
ARG BUILD_TIME
WORKDIR /build
# Install build dependencies
RUN apk add --no-cache \
git \
make \
ca-certificates \
tzdata
# Copy go.mod first for better cache
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy source code
COPY . .
# Build with optimizations and version injection
# Fixed path: ./cmd/hotplex instead of ./cmd/worker
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-s -w \
-X 'github.com/hrygo/hotplex/internal/version.GitCommit=${GIT_SHA}' \
-X 'github.com/hrygo/hotplex/internal/version.BuildDate=${BUILD_TIME}'" \
-o /build/bin/hotplex \
./cmd/hotplex
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2: Runtime
# ─────────────────────────────────────────────────────────────────────────────
FROM alpine:3.21
# Build arguments
ARG GIT_SHA
ARG BUILD_TIME
# Labels for metadata
LABEL maintainer="HotPlex Team <support@hotplex.dev>"
LABEL version="1.16.0"
LABEL git.sha="${GIT_SHA}"
LABEL build.time="${BUILD_TIME}"
LABEL description="HotPlex Worker Gateway - AI Coding Agent access layer"
# Install runtime dependencies
# - ca-certificates: TLS/SSL support
# - curl: health checks
# - tzdata: timezone support
# - git: required by coding agents
# - nodejs & npm: for Claude Code
# - python3: for STT server
# - sqlite: for database backups
RUN apk add --no-cache \
ca-certificates \
curl \
tzdata \
git \
nodejs \
npm \
python3 \
py3-pip \
sqlite \
&& rm -rf /var/cache/apk/*
# Install Claude Code CLI (optional, can also be mounted or installed via env)
# Note: We don't pre-install it to keep the image size down,
# but we provide the environment.
# RUN npm install -g @anthropic-ai/claude-code
# Create non-root user
RUN addgroup -g 1000 hotplex \
&& adduser -D -u 1000 -G hotplex -s /bin/sh -h /home/hotplex hotplex
# Create directories
RUN mkdir -p /etc/hotplex \
/var/lib/hotplex/data \
/var/lib/hotplex/tls \
/var/log/hotplex \
/home/hotplex/.claude \
&& chown -R hotplex:hotplex /etc/hotplex /var/lib/hotplex /var/log/hotplex /home/hotplex/.claude
WORKDIR /home/hotplex
# Copy binary from builder
COPY --from=builder /build/bin/hotplex /usr/local/bin/hotplex
# Copy default config and assets
COPY --chown=hotplex:hotplex configs/ /etc/hotplex/
COPY --chown=hotplex:hotplex scripts/ /home/hotplex/scripts/
# Expose ports
# 8888: WebSocket gateway
# 9999: Admin API
EXPOSE 8888 9999
# Environment variables
ENV HOTPLEX_CONFIG=/etc/hotplex/config.yaml
ENV HOTPLEX_DATA_DIR=/var/lib/hotplex/data
ENV HOTPLEX_LOG_DIR=/var/log/hotplex
ENV PATH="/usr/local/bin:/home/hotplex/.npm-global/bin:${PATH}"
# Switch to non-root user
USER hotplex:hotplex
# Health check using the admin API
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD curl -f http://localhost:9999/admin/health/ready || exit 1
# Entry point
ENTRYPOINT ["/usr/local/bin/hotplex"]
# Default command
CMD ["gateway", "start", "--config", "/etc/hotplex/config.yaml"]