# Use CentOS 7 as base image
FROM centos:7

# Check for updates and install them
RUN yum -y update

# Install epel repo
RUN yum -y install epel-release

# Install xrootd-server package
RUN yum -y install xrootd-server

# Copy authentication directives config file and set the right permissions
COPY auth_file /etc/xrootd/
RUN chown xrootd:xrootd /etc/xrootd/auth_file && \
    chmod 0644 /etc/xrootd/auth_file

# Create a new user called transfer_node, create the home directory and set the default shell
RUN useradd -m -s /bin/bash transfer_node

# Switch to transfer_node user
USER transfer_node

# Set home environment variable
ENV HOME=/home/transfer_node/

# Set the HOME as working directory
WORKDIR $HOME

# Copy xrootd main config file into the current work dir
COPY xrootd.cfg .

# Create a dir to store and expose data
RUN mkdir data

# Execute xrootd service to expose data
CMD /bin/xrootd -c xrootd.cfg ${HOME}/data
