summaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-29 09:57:35 +0300
committerPaul Buetow <paul@buetow.org>2026-04-29 09:57:35 +0300
commit4d71aabf4feb1dcb9c940926fbcc4285525b1c05 (patch)
treece60808e99b1d2a5e19017871052cab57634e4c7 /Dockerfile
parentd6954b4de0261e45d1d57b7f9319114b508817dc (diff)
feat: Create Dockerfile, k8s manifests, and Magefile.go with build/test/install targets (p9)
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile37
1 files changed, 37 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..5654691
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,37 @@
+# syntax=docker/dockerfile:1
+
+# ---- Builder stage ----
+FROM golang:1.23-alpine AS builder
+
+WORKDIR /build
+
+# Install git for go mod download if needed.
+RUN apk add --no-cache git
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY . .
+
+# Build the binary.
+RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o play ./cmd/mediaplayer
+
+# ---- Runtime stage ----
+FROM alpine:3.21
+
+# Install ffmpeg and ffprobe.
+RUN apk add --no-cache ffmpeg
+
+# Create a non-root user (nobody already exists as 65534).
+USER 65534:65534
+
+WORKDIR /app
+
+# Copy the binary and static assets from the builder.
+COPY --from=builder --chown=65534:65534 /build/play /app/play
+COPY --from=builder --chown=65534:65534 /build/web /app/web
+
+# Expose the default HTTP port.
+EXPOSE 8080
+
+ENTRYPOINT ["/app/play"]