Files
Solis/Dockerfile
lucioandClaude Opus 4.6 737a48ac30 Fix security vulnerabilities: XSS, cookie hardening, rate limiter bypass, HSTS, and open redirect
- Fix XSS in showToast() by replacing innerHTML with safe DOM construction via textContent
- Add Secure flag to session and CSRF cookies when base_url uses HTTPS
- Prevent rate limiter bypass by only trusting X-Forwarded-For/X-Real-IP from private/loopback IPs
- Add Strict-Transport-Security header when running behind HTTPS
- Validate short link URLs to prevent open redirects (must be http, https, or relative path)
- Remove runtime config.toml file write from slug length update handler
- Pin Docker base image to alpine:3.20 instead of floating latest tag

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-05-21 20:57:47 -07:00

64 lines
1.7 KiB
Docker

# ==========================================
# Build Stage
# ==========================================
FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS builder
WORKDIR /build
# Install git and ca-certificates (needed for downloading modules and SSL)
RUN apk add --no-cache git ca-certificates
# Copy go.mod and go.sum and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source code
COPY . .
# Compile static binary optimized for Raspberry Pi Zero (ARMv6, no CGO)
# - ldflags "-s -w" removes symbol tables and debugging info, reducing binary size
ARG TARGETOS=linux
ARG TARGETARCH=arm
ARG TARGETVARIANT=v6
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=6 \
go build -ldflags="-s -w" -o solis main.go
# ==========================================
# Final Stage
# ==========================================
FROM alpine:3.20
# Install basic certificates and tools
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
# Create a non-root user for security
RUN addgroup -S solis && adduser -S solis -G solis
# Create data directory and change ownership
RUN mkdir -p /app/data && chown -R solis:solis /app/data
# Copy the compiled binary from the builder
COPY --from=builder /build/solis /app/solis
# Copy example config (and default config)
COPY config.toml.example /app/config.toml.example
COPY config.toml.example /app/config.toml
# Set permissions for the non-root user
RUN chown -R solis:solis /app
# Switch to the non-root user
USER solis
# Persist DB and uploads in a mounted volume
VOLUME ["/app/data"]
# Expose the default premium port
EXPOSE 8889
# Run the lightweight binary
ENTRYPOINT ["/app/solis", "--config", "/app/config.toml"]