FROM docker.repo.eng.netapp.com/alpine:3.19.0
LABEL "com.vmware.srm.sra"=""
LABEL "perl"="5.38.3-r0"
LABEL "alpine"="3.19.0"

RUN echo "http://repomirror-rtp.eng.netapp.com/alpine-linux/v3.19/main" > /etc/apk/repositories; \
    echo "http://repomirror-rtp.eng.netapp.com/alpine-linux/v3.19/community" >> /etc/apk/repositories

RUN apk update
# we need make, gcc and g++ to install CryptX

RUN apk add --no-cache make=4.4.1-r2
RUN apk add --no-cache gcc=13.2.1_git20231014-r0
RUN apk add --no-cache g++=13.2.1_git20231014-r0
RUN apk add --no-cache openssl
RUN apk add --no-cache perl-module-install
RUN apk add --no-cache perl-class-accessor
RUN apk add --no-cache perl-crypt-openssl-x509
RUN apk add --no-cache perl-datetime
RUN apk add --no-cache perl-time-duration-parse
RUN apk add --no-cache perl-universal-require


RUN apk --no-cache add perl  && \
    apk add perl-dev=5.38.3-r0 && \
    apk add perl-xml-simple=2.25-r3 && \
    apk add perl-socket6=0.29-r9 && \
    apk add perl-lwp-protocol-https=6.11-r0 && \
    apk add perl-crypt-cbc=3.04-r1 && \
    apk add perl-crypt-des=2.07-r13 && \
    apk add perl-class-inspector=1.36-r3

RUN mkdir -p /srm/sra
RUN addgroup --gid 660 srm && adduser --disabled-password --home /srm/sra --ingroup srm --uid 660 srm

WORKDIR /srm/sra
ADD . /srm/sra
#install CryptX library
RUN tar -xvzf tp-lib/CryptX-0.066.tar.gz;\
    cd CryptX-0.066;\
    perl Makefile.PL;\
    make;\
    make install ;
	
RUN tar -xvzf tp-lib/File-ShareDir-Install-0.14.tar.gz;\
    cd File-ShareDir-Install-0.14;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/File-ShareDir-1.118.tar.gz;\
    cd File-ShareDir-1.118;\
    perl Makefile.PL;\
    make;\
    make install ;


RUN tar -xvzf tp-lib/Tiny-OpenSSL-0.1.3.tar.gz;\
    cd Tiny-OpenSSL-0.1.3;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Moo-2.005004.tar.gz;\
    cd Moo-2.005004;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Exporter-5.74.tar.gz;\
    cd Exporter-5.74;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Role-Tiny-2.002004.tar.gz;\
    cd Role-Tiny-2.002004;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Carp-1.50.tar.gz;\
    cd Carp-1.50;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Capture-Tiny-0.48.tar.gz;\
    cd Capture-Tiny-0.48;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Exporter-Tiny-1.006000.tar.gz;\
    cd Exporter-Tiny-1.006000;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Scalar-List-Utils-1.63.tar.gz;\
    cd Scalar-List-Utils-1.63;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Type-Tiny-2.000001.tar.gz;\
    cd Type-Tiny-2.000001;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/YAML-Tiny-1.73.tar.gz;\
    cd YAML-Tiny-1.73;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Path-Tiny-0.144.tar.gz;\
    cd Path-Tiny-0.144;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN tar -xvzf tp-lib/Sub-Quote-2.006006.tar.gz;\
    cd Sub-Quote-2.006006;\
    perl Makefile.PL;\
    make;\
    make install ;
	
RUN tar -xvzf tp-lib/File-Slurp-9999.32.tar.gz;\
    cd File-Slurp-9999.32;\
    perl Makefile.PL;\
    make;\
    make install ;
	
RUN tar -xvzf tp-lib/Crypt-X509-0.54.tar.gz;\
    cd Crypt-X509-0.54;\
    perl Makefile.PL;\
    make;\
    make install ;
	
RUN tar -xvzf tp-lib/Convert-ASN1-0.33.tar.gz;\
    cd Convert-ASN1-0.33;\
    perl Makefile.PL;\
    make;\
    make install ;
	
RUN tar -xvzf tp-lib/TimeDate-2.33.tar.gz;\
    cd TimeDate-2.33;\
    perl Makefile.PL;\
    make;\
    make install ;
	
RUN tar -xvzf tp-lib/Net-SSL-ExpireDate-1.24.tar.gz;\
    cd Net-SSL-ExpireDate-1.24;\
    perl Makefile.PL;\
    make;\
    make install ;

RUN ln -s command.pl command && \
    chmod a+x command.pl && \
	mkdir conf 
RUN chown -R srm:srm /srm
USER srm

CMD ["/srm/sra/start.sh"]
