This repository has been archived on 2026-07-15. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
drive/backend/Dockerfile
Elijah dbd3a868ed
All checks were successful
Automated Container Build / build-and-push (push) Successful in 5m46s
Update Go version to support bodgit/sevenzip v1.6.4
2026-06-01 09:03:41 -07:00

47 lines
966 B
Docker

# Build stage
FROM golang:alpine AS builder
RUN apk add --no-cache gcc musl-dev sqlite-dev git
WORKDIR /build
COPY go.mod ./
# Copy everything and generate go.sum inside the container
COPY . .
RUN go mod tidy
RUN go mod download
RUN CGO_ENABLED=1 GOOS=linux go build -tags sqlite_fts5 -ldflags="-s -w" -o /build/drive ./main.go
# Runtime stage
FROM alpine:3.21
RUN apk add --no-cache \
ffmpeg \
exiftool \
sqlite \
ca-certificates \
mailcap \
tzdata
# Create non-root user
RUN addgroup -S drive && adduser -S drive -G drive
WORKDIR /app
COPY --from=builder /build/drive /app/drive
COPY --from=builder /build/templates /app/templates
# Create default directories
RUN mkdir -p /app/data /storage && \
chown -R drive:drive /app /app/data /storage
USER drive
EXPOSE 5827
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://127.0.0.1:5827/health || exit 1
ENTRYPOINT ["/app/drive"]