# Use CentOS 8 as base image
FROM centos:8

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

# Set up a workdir for the container
WORKDIR /home/transfer_service/

# Copy the source code of the server app
COPY wait-for-it.sh *.py ./
RUN chown transfer_service wait-for-it.sh *.py && \ 
    chmod 755 wait-for-it.sh *.py        

# Install epel repo
RUN dnf update -y && dnf -y install epel-release
    
# Install pika and redis libraries
RUN dnf -y install python3-pika python3-redis nano
    
# Install xrootd with python bindings
RUN dnf install -y xrootd-client xrootd-client-devel xrootd python3-xrootd

# Run commands as transfer_service user
#USER transfer_service

# Create a 'store' directory with a file
RUN mkdir /home/transfer_service/store && touch /home/transfer_service/store/foo.txt && \
    chown -R transfer_service:transfer_service /home/transfer_service/store && \
    chmod -R 755 /home/transfer_service/store

# Run a shell
CMD /bin/bash
