-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile.api
More file actions
57 lines (44 loc) · 1.44 KB
/
Dockerfile.api
File metadata and controls
57 lines (44 loc) · 1.44 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
# Multi-stage build for Lophiid API Server
FROM golang:1.24.7-bookworm AS builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
protobuf-compiler \
protoc-gen-go \
libmagic-dev \
libssl-dev \
pkg-config \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install compatible gRPC plugin version
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
WORKDIR /workspace
COPY . .
# Compile protobuf files
RUN ./compile_proto.sh
# Build API server
RUN go build ./cmd/api/api_server.go
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies including curl for health checks
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create directories with proper permissions for user namespace mapping
RUN mkdir -p /app/config /app/logs && \
chmod 755 /app && \
chmod 777 /app/logs
# Copy binary (correct Bazel output path)
COPY --from=builder /workspace/api_server /app/api_server
RUN chmod +x /app/api_server
# Note: USER will be set via docker-compose user: directive for namespace mapping
WORKDIR /app/config
# Expose API port
EXPOSE 62212
# Health check - check if API port is accepting connections
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -s http://localhost:62212/ >/dev/null || exit 1
CMD ["/app/api_server", "-c", "api-config.yaml"]