FROM debian:13-slim

LABEL description="Virola Server"

ENV VIROLA_DIR="/virola"

#Default port to listen on if user did not pass during build with option --build-arg PORT=443
ARG PORT=7777
ENV PORT=${PORT}
EXPOSE ${PORT}/tcp
EXPOSE ${PORT}/udp

ARG PACKAGE_NAME
ADD ${PACKAGE_NAME} /

#Install required packages and virola server, aftewards clean up
RUN apt-get update && apt-get dist-upgrade -y \
&& apt-get install -y libfontconfig libxext6 libxcb-glx0 libx11-xcb1 libxi6 libxrender1 libdbus-1-3 libglib2.0-0 libgl1 \
&& apt-get install -y libegl1 libfontconfig1 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-xinerama0 libxcb-xkb1 libsm6 libxkbcommon0 libxkbcommon-x11-0 libgl1 \
&& apt-get install -y ca-certificates \
&& apt install -y /virola-server-debian-* \
&& rm -rf /virola-server-debian-* \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

#START VIROLA SERVER
CMD /usr/bin/virola-server --listen 0.0.0.0:${PORT} --storage-dir ${VIROLA_DIR}/ --log-dir ${VIROLA_DIR}/logs
