FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:debian12

WORKDIR /var/app

USER root

# Run updates
RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get -y install curl git jq ssh \
  && apt-get -y clean \
  && rm -rf /var/lib/apt/lists/*

# Install and configure tfswitch
RUN curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash

USER worker

ENV BIN_DIR=/var/app/.bin
ENV PATH="$BIN_DIR:$PATH"
RUN mkdir $BIN_DIR

RUN mkdir -p ~/.ssh
RUN ssh-keyscan github.com > ~/.ssh/known_hosts

COPY --chown=worker:worker replace-provider.sh ./
RUN chmod +x ./replace-provider.sh

ENTRYPOINT ["./replace-provider.sh"]
