Files
gohoarder/Dockerfile.server
T
lukaszraczylo f936dfa359 Enable CGO for all GoHoarder binaries to support SQLite
Changes:
- Set CGO_ENABLED=1 for gohoarder main binary in .goreleaser.yaml
- Add sqlite-libs and musl to Dockerfile.server
- Add sqlite-libs and musl to Dockerfile.scanner

All Go binaries that interact with SQLite now have CGO enabled:
 gohoarder (main binary) - used by server and scanner
 migrate (migration tool)

Runtime containers include necessary C libraries:
 Dockerfile.server - SQLite runtime support
 Dockerfile.scanner - SQLite runtime support
 Dockerfile.migrate - SQLite runtime support

This fixes: 'Binary was compiled with CGO_ENABLED=0, go-sqlite3 requires cgo'
2026-01-03 21:41:59 +00:00

53 lines
1.4 KiB
Docker

# Application Engine - GoHoarder Server
ARG TARGETOS
ARG TARGETARCH
FROM alpine:latest
# Install runtime dependencies (including CGO/SQLite dependencies)
RUN apk add --no-cache \
ca-certificates \
tzdata \
sqlite-libs \
musl \
&& update-ca-certificates
# Create non-root user
RUN addgroup -g 1000 gohoarder && \
adduser -D -u 1000 -G gohoarder gohoarder
# Create necessary directories with proper permissions
RUN mkdir -p /var/cache/gohoarder \
/var/lib/gohoarder/metadata \
/tmp/gohoarder && \
chown -R gohoarder:gohoarder /var/cache/gohoarder \
/var/lib/gohoarder \
/tmp/gohoarder && \
chmod -R 750 /var/cache/gohoarder \
/var/lib/gohoarder
# Copy binary (from platform-specific path)
ARG TARGETOS
ARG TARGETARCH
COPY ${TARGETOS}/${TARGETARCH}/gohoarder /usr/local/bin/gohoarder
RUN chmod +x /usr/local/bin/gohoarder
# Copy example config
COPY config.yaml.example /etc/gohoarder/config.yaml.example
WORKDIR /var/cache/gohoarder
USER gohoarder
# Expose ports
# 8080: Main proxy port
# 9090: Metrics/health port
EXPOSE 8080 9090
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD ["/usr/local/bin/gohoarder", "version"] || exit 1
# Run the server
ENTRYPOINT ["/usr/local/bin/gohoarder"]
CMD ["serve"]