-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
87 lines (66 loc) · 3.7 KB
/
Copy pathDockerfile
File metadata and controls
87 lines (66 loc) · 3.7 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1: Build frontend with Bun
# ─────────────────────────────────────────────────────────────────────────────
FROM oven/bun:1 AS frontend
WORKDIR /frontend
# Install dependencies first (layer cache)
COPY static/frontend/package.json static/frontend/bun.lock* static/frontend/bun.lockb* ./
RUN bun install
# Copy source and build
COPY static/frontend/ ./
RUN bun run build
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2: Build Go binary
# ─────────────────────────────────────────────────────────────────────────────
FROM golang:1.25-alpine AS builder
# Build arguments for version injection
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_DATE=unknown
WORKDIR /src
# Install git (needed for go module resolution if any use git)
RUN apk add --no-cache git
# Cache Go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy full source
COPY . .
# Copy built frontend assets into the embed directory
COPY --from=frontend /frontend/dist ./static/frontend/dist
# Build static binary
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-s -w \
-X 'github.com/ekilie/beamdrop/config.VERSION=${VERSION}' \
-X 'github.com/ekilie/beamdrop/config.Commit=${COMMIT}' \
-X 'github.com/ekilie/beamdrop/config.BuildDate=${BUILD_DATE}'" \
-o /beamdrop ./cmd/beam
# ─────────────────────────────────────────────────────────────────────────────
# Stage 3: Minimal runtime image
# ─────────────────────────────────────────────────────────────────────────────
FROM alpine:3.21
LABEL org.opencontainers.image.title="BeamDrop" \
org.opencontainers.image.description="Local-first file sharing with S3-compatible API" \
org.opencontainers.image.source="https://github.com/ekilie/beamdrop" \
org.opencontainers.image.url="https://github.com/ekilie/beamdrop" \
org.opencontainers.image.licenses="MIT"
# Install ca-certificates for HTTPS and wget for HEALTHCHECK
RUN apk add --no-cache ca-certificates wget \
&& addgroup -S beamdrop \
&& adduser -S -G beamdrop -h /data beamdrop
# Copy the static binary
COPY --from=builder /beamdrop /usr/local/bin/beamdrop
# /data is the shared directory — mount a volume here for persistence.
# The SQLite DB, logs, and uploaded files all live under this path.
RUN mkdir -p /data && chown beamdrop:beamdrop /data
VOLUME /data
# Default port
EXPOSE 7777
# Default environment — beamdrop reads BEAMDROP_* env vars natively
ENV BEAMDROP_DIR=/data \
BEAMDROP_PORT=7777
# Health check using the lightweight liveness probe
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD ["wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:7777/health/live"]
USER beamdrop:beamdrop
ENTRYPOINT ["beamdrop"]
CMD ["--dir", "/data"]