# Official daloRADIUS Dockerfile for freeradius
# GitHub: https://github.com/lirantal/daloradius
#
# Build image:
# 1. git pull git@github.com:lirantal/daloradius.git
# 2. docker build -t lirantal/daloradius -f Dockerfile-freeradius
#
# Run the container:
# 1. docker run -p 80:80 -d lirantal/dalofreeradius

FROM freeradius/freeradius-server:latest
MAINTAINER Liran Tal <liran.tal@gmail.com>

LABEL Description="freeradius Docker based on Ubuntu 20.04 LTS, optimized for daloRADIUS." \
	License="GPLv2" \
	Usage="docker build -t lirantal/dalofreeradius -f Dockerfile-freeradius && docker run -d -p 80:80 lirantal/dalofreeradius" \
	Version="1.0"

ENV DEBIAN_FRONTEND noninteractive

# default timezone
ENV TZ Europe/Vienna

RUN apt-get update \
	&& apt-get install --yes --no-install-recommends \
		apt-utils \
		ipcalc \
		tzdata \
		net-tools \
		mariadb-client \
		libmysqlclient-dev \
		unzip \
		wget \
	&& rm -rf /var/lib/apt/lists/*

# Create directories
# /data should be mounted as volume to avoid recreation of database entries
RUN mkdir /app /data /internal_data
WORKDIR /app

# Copy init script to image
ADD ./init-freeradius.sh /app

# Make init.sh script executable
RUN chmod +x /app/init-freeradius.sh

# Expose FreeRADIUS Ports
EXPOSE 1812 1813

# Run the script which executes freeradius in foreground
CMD ["/app/init-freeradius.sh"]
ENTRYPOINT ["/app/init-freeradius.sh"]
