# SamCloud FileBrowser - Development Build FROM node:20-alpine AS frontend-builder # Install pnpm RUN npm install -g pnpm # Set working directory WORKDIR /app # Copy frontend source COPY frontend/ ./ # Install dependencies RUN pnpm install # Build frontend (this will be overridden by volume mounts) RUN pnpm run build # Build the Go backend FROM golang:alpine AS backend-builder # Install git RUN apk add --no-cache git # Set working directory WORKDIR /app # Copy Go source COPY . . # Copy the built frontend COPY --from=frontend-builder /app/dist ./frontend/dist # Build the Go binary RUN go mod download RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o filebrowser . # Final development stage FROM alpine:latest # Install necessary packages RUN apk --no-cache add ca-certificates tini # Create filebrowser user RUN addgroup -g 1000 filebrowser && \ adduser -D -u 1000 -G filebrowser filebrowser # Set working directory WORKDIR /config # Copy the binary COPY --from=backend-builder /app/filebrowser /usr/local/bin/filebrowser # Create directories RUN mkdir -p /config /database /srv && \ chown -R filebrowser:filebrowser /config /database /srv # Switch to non-root user USER filebrowser # Expose port EXPOSE 8080 # Entry point ENTRYPOINT ["tini", "--", "filebrowser", "--config", "/config/filebrowser.json"]