# home assistant prefers to pass in the image name as an argument
# if changing base image, make sure to update build.yaml and docker-compose.yaml
ARG BUILD_FROM
FROM $BUILD_FROM

# the rest of this script assumes alpine linux
RUN apk update && apk add --no-cache uv libpcap iptables nginx tcpdump

# turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Save version to access in the container
# TODO figure out how to pass this in from the build system
# ARG VERSION=unknown
# RUN echo "${VERSION}" > /app/VERSION

# copy read-only data
COPY ./data/GeoLite2-Country_20191224/GeoLite2-Country.mmdb ./data/GeoLite2-Country_20191224/GeoLite2-Country.mmdb
COPY ./data/*.json ./data/
COPY ./data/policies/*.json ./data/policies/
COPY ./data/*.txt ./data/
COPY ./data/domains/* ./data/domains/

# set up server
COPY pyproject.toml ./pyproject.toml
COPY uv.lock ./uv.lock
COPY main.py ./main.py
COPY app ./app
COPY model ./model
COPY inspector ./inspector
COPY scan ./scan
COPY shared ./shared

RUN uv sync

# copy system config files
COPY rootfs /

# copy static files for loading page
COPY app/static/css/styles.css /var/www/html/styles.css