#
# This source file is part of the Stanford Spezi open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#

FROM alpine:3.19

LABEL org.opencontainers.image.authors="Philipp Zagar <zagar@stanford.edu>" \
      org.opencontainers.image.version="0.1" \
      org.opencontainers.image.title="stanfordspezi/avahi-sidecar" \
      org.opencontainers.image.description="Avahi sidecar discovering mDNS services" \
      org.opencontainers.image.url="https://ghcr.io/stanfordspezi/avahi-sidecar" \
      org.opencontainers.image.source="https://github.com/StanfordSpezi/SpeziLLM"

# Install Avahi daemon
RUN apk --no-cache --no-progress add avahi avahi-tools dbus

# Setup services
RUN rm -rf /etc/avahi/services
COPY services/ /etc/avahi/services

# Run Avahi daemon with non-root user, avoid daemonizing to keep container running
COPY docker-entrypoint-sidecar.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

# Create the D-Bus system bus socket directory
RUN mkdir -p /var/run/dbus && \
    chown messagebus:messagebus /var/run/dbus

ENTRYPOINT ["docker-entrypoint.sh"]