# 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 tape_frontend, create the home directory and set the default shell
RUN useradd -m -s /bin/bash tape_frontend

# Switch to tape_frontend user
USER tape_frontend

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

# Set the HOME as working directory
WORKDIR $HOME

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

# Create a dir with some data to expose
RUN mkdir data
COPY aaa ./data/aaa

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