FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1

WORKDIR /app

RUN useradd --create-home --uid 10001 meshnet \
    && mkdir -p /var/lib/meshnet \
    && chown meshnet:meshnet /var/lib/meshnet

COPY packages/contracts /app/packages/contracts
COPY packages/tracker /app/packages/tracker
COPY packages/relay /app/packages/relay

RUN python -m pip install --upgrade pip setuptools wheel \
    && python -m pip install \
      -e /app/packages/contracts \
      -e /app/packages/tracker \
      -e /app/packages/relay

USER meshnet

EXPOSE 8081 8765

CMD ["meshnet-tracker", "start", "--host", "0.0.0.0", "--port", "8081"]
