-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (49 loc) · 1.5 KB
/
Dockerfile
File metadata and controls
66 lines (49 loc) · 1.5 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
# Multi-stage build for KaflowSQL
# Support for multiple architectures: linux/amd64, linux/arm64, linux/arm/v7
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
# Build stage - use Ubuntu for better ARM64 library support
FROM golang:1.24.1 AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
make \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 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 the engine for the target platform
RUN echo "Building for $(uname -m) with CGO"; \
CGO_ENABLED=1 go build -ldflags="-w -s" -o bin/engine cmd/engine/main.go
# Runtime stage - use Ubuntu for consistent ARM64 support
FROM ubuntu:24.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -g 1001 kaflowsql && \
useradd -u 1001 -g kaflowsql -m -s /bin/bash kaflowsql
# Create necessary directories
RUN mkdir -p /data/rocksdb /app/pipelines /app/configs && \
chown -R kaflowsql:kaflowsql /data /app
# Copy binary from builder
COPY --from=builder /app/bin/engine /usr/local/bin/
# Set working directory
WORKDIR /app
# Switch to non-root user
USER kaflowsql
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD pgrep engine || exit 1
# Default command
CMD ["engine"]