Introduce new environment variables to control the behavior of one-time download boxes: - `WARPBOX_ONE_TIME_DOWNLOAD_EXPIRY_SECONDS`: Sets the lifetime of a one-time box after uploads are complete. - `WARPBOX_ONE_TIME_DOWNLOAD_RETRY_ON_FAILURE`: Determines whether a box remains available if the ZIP creation or transfer fails. To support these settings, the ZIP delivery process was refactored to use a temporary file. This ensures that a one-time box is only marked as consumed after the file has been successfully transferred to the client, preventing data loss on network interruptions. Additionally, added a `DecorateFiles` helper in the box store to reduce code duplication.
66 lines
1.6 KiB
Docker
66 lines
1.6 KiB
Docker
# Stage 1: Build
|
|
FROM golang:1.23-alpine AS builder
|
|
|
|
RUN apk add --no-cache git ca-certificates
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy go modules and download dependencies
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download && go mod verify
|
|
|
|
# Copy source code and static assets
|
|
COPY cmd/ cmd/
|
|
COPY lib/ lib/
|
|
COPY static/ static/
|
|
COPY templates/ templates/
|
|
|
|
# Build the binary
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o warpbox ./cmd/main.go
|
|
|
|
# Stage 2: Runtime
|
|
FROM alpine:3.21
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
|
|
# Create non-root user
|
|
RUN addgroup -S warpbox && adduser -S warpbox -G warpbox
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /build/warpbox .
|
|
|
|
# Copy static assets
|
|
COPY --from=builder /build/static/ static/
|
|
COPY --from=builder /build/templates/ templates/
|
|
|
|
# Create data directory
|
|
RUN mkdir -p /app/data/uploads /app/data/db && chown -R warpbox:warpbox /app/data
|
|
|
|
# Switch to non-root user
|
|
USER warpbox
|
|
|
|
# Environment variables
|
|
ENV WARPBOX_DATA_DIR=/app/data \
|
|
WARPBOX_GUEST_UPLOADS_ENABLED=true \
|
|
WARPBOX_API_ENABLED=true \
|
|
WARPBOX_ZIP_DOWNLOADS_ENABLED=true \
|
|
WARPBOX_ONE_TIME_DOWNLOADS_ENABLED=true \
|
|
WARPBOX_ONE_TIME_DOWNLOAD_EXPIRY_SECONDS=604800 \
|
|
WARPBOX_ONE_TIME_DOWNLOAD_RETRY_ON_FAILURE=false \
|
|
WARPBOX_ADMIN_ENABLED=true \
|
|
WARPBOX_GLOBAL_MAX_FILE_SIZE_MB=2048 \
|
|
WARPBOX_GLOBAL_MAX_BOX_SIZE_MB=4096 \
|
|
WARPBOX_DEFAULT_GUEST_EXPIRY_SECONDS=3600 \
|
|
WARPBOX_MAX_GUEST_EXPIRY_SECONDS=172800 \
|
|
WARPBOX_BOX_POLL_INTERVAL_MS=5000 \
|
|
WARPBOX_THUMBNAIL_BATCH_SIZE=10 \
|
|
WARPBOX_THUMBNAIL_INTERVAL_SECONDS=30
|
|
|
|
EXPOSE 8080
|
|
|
|
VOLUME ["/app/data"]
|
|
|
|
CMD ["./warpbox", "run", "--addr", ":8080"]
|