FROM debian:jessie
LABEL maintainer="Yaltik - Fabien Bourgeois <fabien@yaltik.com>"

# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8

# Install dependencies
RUN apt-get update && \
      apt-get install -y --no-install-recommends python3 python3-pip && \
      apt-get clean && rm -rf /var/lib/apt/lists/*

# Create radicale user
RUN useradd radicale -md /opt/radicale
WORKDIR /opt/radicale
USER radicale

# Install Radicale
# v2.1.9 because of regressions on v2.1.10+ on SSL handling
ENV VERSION 2.1.9
RUN pip3 install --user --upgrade radicale==${VERSION}
COPY config /opt/radicale/radicale.conf
RUN mkdir /opt/radicale/storage

# Persistent storage for data and configuration
VOLUME /opt/radicale/storage

# TCP port of Radicale
EXPOSE 5232

# Run Radicale
CMD [".local/bin/radicale", "--config", "/opt/radicale/radicale.conf"]