FROM rabbitmq:3-management-alpine

# Copy configuration files
COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
COPY definitions.json /etc/rabbitmq/definitions.json

# Enable management plugin and set definitions
RUN rabbitmq-plugins enable --offline rabbitmq_management rabbitmq_management_agent

# Set proper permissions
RUN chmod 644 /etc/rabbitmq/rabbitmq.conf
RUN chmod 644 /etc/rabbitmq/definitions.json

# Expose ports
EXPOSE 5672 15672

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD rabbitmq-diagnostics ping

# Start RabbitMQ
CMD ["rabbitmq-server"]
