-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (42 loc) · 2.31 KB
/
Dockerfile
File metadata and controls
54 lines (42 loc) · 2.31 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
# =============================================================================
# Homelab Dashboard — Dockerfile
# Multi-stage: Go binary compiled in builder, copied to bare Alpine runtime.
# No PHP, no nginx, no FPM — just a single static binary + Alpine base.
# =============================================================================
# ── Stage 1: build ────────────────────────────────────────────────────────────
# Always build on the native platform so Go cross-compiles instead of
# running under QEMU emulation — dramatically faster for arm64 targets.
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder
ARG TARGETOS
ARG TARGETARCH
ARG GIT_SHA=dev
WORKDIR /build
# Separate layer so js-yaml is only re-downloaded when this line changes
RUN wget -q -O js-yaml.min.js \
https://cdn.jsdelivr.net/npm/js-yaml@4/dist/js-yaml.min.js
# Copy source and assets
COPY go.mod main.go index.html ./
COPY styles.css app.js VERSION release-notes.md ./
COPY api-managers/ api-managers/
COPY js/ js/
# Compile — cross-compile to target arch, reuse Go build cache between runs
# -mod=mod allows fetching dependencies declared in go.mod at build time
RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -mod=mod -ldflags="-s -w -X main.commitSHA=${GIT_SHA}" -o labdash .
# ── Stage 2: runtime ──────────────────────────────────────────────────────────
FROM alpine:3.21
# CA certificates for outbound HTTPS status checks
RUN apk add --no-cache ca-certificates
COPY --from=builder /build/labdash /labdash
COPY example.services.yaml /example.services.yaml
# Runtime config directory (mount point for user data)
RUN mkdir -p /config/logos
# ── Default port (override with -e PORT=xxxx) ─────────────────────────────────
ENV PORT=6969
# ── Beta mode: disables caching (baked in at build time, overridable at runtime)
ARG BETA=false
ENV BETA=${BETA}
EXPOSE 6969
ENTRYPOINT ["/labdash"]