# DSMS Node - Dezentrales Daten Speicher System
# Basiert auf IPFS für BreakPilot PWA

FROM ipfs/kubo:v0.24.0

LABEL maintainer="BreakPilot <dev@breakpilot.app>"
LABEL description="DSMS Node for BreakPilot - Decentralized Storage System"

# Environment variables
ENV IPFS_PATH=/data/ipfs
ENV IPFS_PROFILE=server

# Expose ports
# 4001 - Swarm (P2P)
# 5001 - API
# 8080 - Gateway
EXPOSE 4001
EXPOSE 5001
EXPOSE 8080

# Copy initialization script with correct permissions for ipfs user
USER root
COPY init-dsms.sh /container-init.d/001-init-dsms.sh
RUN chmod 755 /container-init.d/001-init-dsms.sh && chown 1000:users /container-init.d/001-init-dsms.sh
USER ipfs

# Health check - use ipfs id which works for standalone node
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
  CMD ipfs id > /dev/null 2>&1 || exit 1

# Default command
CMD ["daemon", "--migrate=true", "--enable-gc"]
