FROM alpine

ENV PERL_MM_USE_DEFAULT=1 \
    BUILD_PKGS="build-base curl expat expat-dev libxml2-dev openssl openssl-dev perl perl-dev wget"

RUN apk --update upgrade && apk --no-cache add $BUILD_PKGS
RUN perl -MCPAN -e 'install App::cpanminus'
RUN cpanm --self-upgrade && cpanm local::lib

WORKDIR /app

# Install dependencies
COPY cpanfile cpanfile
RUN (cpanm --installdeps -nq .) || cat ~/.cpanm/build.log

# Copy over the rest of the module
COPY . .

# By default, treat the container as an arbitrary script executing w/in context
ENTRYPOINT ["carton", "exec", "--"]
