-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (35 loc) · 1.81 KB
/
Dockerfile
File metadata and controls
43 lines (35 loc) · 1.81 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
FROM golang:1.26 AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
ARG VERSION=dev
ARG COMMIT=
COPY . .
# Build for linux/amd64 and linux/arm64 so both are available for self-hosted download.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath \
-ldflags="-s -w -X github.com/rinseaid/identree/internal/server.version=${VERSION} -X github.com/rinseaid/identree/internal/server.commit=${COMMIT}" \
-o /app/identree-linux-amd64 ./cmd/identree/ && \
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath \
-ldflags="-s -w -X github.com/rinseaid/identree/internal/server.version=${VERSION} -X github.com/rinseaid/identree/internal/server.commit=${COMMIT}" \
-o /app/identree-linux-arm64 ./cmd/identree/
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates wget && \
rm -rf /var/lib/apt/lists/*
RUN groupadd -r identree && useradd -r -g identree -s /sbin/nologin identree && \
mkdir -p /data /config && chown identree:identree /data /config
# Install both arch binaries; symlink the native one as the runtime binary.
COPY --from=builder /app/identree-linux-amd64 /usr/local/bin/identree-linux-amd64
COPY --from=builder /app/identree-linux-arm64 /usr/local/bin/identree-linux-arm64
RUN chmod 755 /usr/local/bin/identree-linux-amd64 /usr/local/bin/identree-linux-arm64 && \
arch=$(uname -m) && \
case "$arch" in \
x86_64) ln -sf /usr/local/bin/identree-linux-amd64 /usr/local/bin/identree ;; \
aarch64) ln -sf /usr/local/bin/identree-linux-arm64 /usr/local/bin/identree ;; \
*) echo "Unsupported arch: $arch" >&2; exit 1 ;; \
esac
USER identree
EXPOSE 8090
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD wget --spider -q http://localhost:8090/healthz || exit 1
ENTRYPOINT ["identree", "serve"]