FROM alpine:latest
RUN apk add --no-cache python3 git bash make coreutils findutils rsync util-linux sqlite shadow jq
RUN adduser -D -u 1000 -s /bin/bash agent
RUN mkdir -p /usr/local/lib/icrshim /etc/icr /var/icr /run/icr /opt/icr \
 && chmod 700 /var/icr /opt/icr && touch /var/log/icr_cmd.log && chmod 666 /var/log/icr_cmd.log
COPY shim/ /usr/local/lib/icrshim/
RUN chmod 755 /usr/local/lib/icrshim/*.py \
 && for t in rm git mkdir ls cat cp mv stat find; do \
      printf '#!/bin/sh\nexec python3 /usr/local/lib/icrshim/shim.py %s "$@"\n' $t > /usr/local/bin/$t; chmod 755 /usr/local/bin/$t; done \
 && for t in cloudctl terraform awsctl envctl mailctl platformctl icloudctl prisma gh zc curl; do \
      printf '#!/bin/sh\nexec python3 /usr/local/lib/icrshim/cli.py %s "$@"\n' $t > /usr/local/bin/$t; chmod 755 /usr/local/bin/$t; done
