-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (37 loc) · 1.42 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (37 loc) · 1.42 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
# Hercules Distributed System - Multi-Server Dockerfile
# Supports building images for: master_server, chunk_server, gateway_server
# Build with: docker build --build-arg SERVER_TYPE=<type> -t hercules-<type> .
FROM golang:tip-alpine3.22 AS builder
WORKDIR /build
RUN apk add --no-cache file
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
# Build static binary; adjust if main in subdir (e.g., cd hercules && go build -o app . && mv app ..)
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o app . && \
chmod +x app && \
file app
# Stage 2: Runtime
FROM alpine:3.20
ARG SERVER_TYPE=chunk_server
ENV SERVER_TYPE=${SERVER_TYPE}
ENV LOG_LEVEL="info"
RUN apk add --no-cache ca-certificates procps iputils netcat-openbsd net-tools && \
addgroup -g 1001 -S hercules && \
adduser -S -D -H -u 1001 -h /tmp -s /sbin/nologin -G hercules -g hercules hercules
RUN mkdir -p /data/master/metadata \
/data/chunks /data/gateway && \
chown -R hercules:hercules /data
WORKDIR /
COPY --from=builder /build/app /app
COPY entrypoint.sh /entrypoint.sh
RUN chown hercules:hercules /app /entrypoint.sh && \
chmod 755 /app /entrypoint.sh && \
ls -la /app /entrypoint.sh
USER hercules
EXPOSE 8081-8090 9090 8089
ENV HEALTH_PORT=8081
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=5 \
CMD nc -z 127.0.0.1 ${HEALTH_PORT} || exit 1
VOLUME ["/data"]
ENTRYPOINT ["/entrypoint.sh"]