-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (39 loc) · 1.48 KB
/
Dockerfile
File metadata and controls
57 lines (39 loc) · 1.48 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
# Build stage - Install Go from source
FROM debian:bookworm-slim AS go-installer
RUN apt-get update && apt-get install -y --no-install-recommends \
wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ARG GO_VERSION=1.26.1
ARG TARGETARCH
RUN wget -q "https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz" \
&& tar -C /usr/local -xzf "go${GO_VERSION}.linux-${TARGETARCH}.tar.gz" \
&& rm "go${GO_VERSION}.linux-${TARGETARCH}.tar.gz"
# Build stage
FROM debian:bookworm-slim AS builder
COPY --from=go-installer /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"
RUN apt-get update && apt-get install -y --no-install-recommends \
git make gcc libc6-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build netrunner with static linking for portability
RUN CGO_ENABLED=0 go build -o bin/netrunner .
# Runtime stage - use debian-slim for better QEMU compatibility
FROM debian:12-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary
COPY --from=builder /build/bin/netrunner /usr/local/bin/netrunner
# Create netrunner user
RUN useradd -r -m -d /var/lib/netrunner netrunner
# Create directories
RUN mkdir -p /var/lib/netrunner && chown -R netrunner:netrunner /var/lib/netrunner
USER netrunner
EXPOSE 8080 8081
ENTRYPOINT ["/usr/local/bin/netrunner"]