# Use latest alpine-derived Python base image
FROM python:3.12-slim 

RUN apt-get update
RUN apt-get install -y git
RUN git clone https://github.com/Linus2punkt0/bluesky-crossposter.git \
    && cd bluesky-crossposter \
    && git chechout main \
    && git pull origin main
# RUN git clone https://github.com/coissac/bluesky-crossposter.git
RUN rm -f bluesky-crossposter/Dockerfile \
          bluesky-crossposter/docker-compose.yml \
          bluesky-crossposter/env.example
RUN mv bluesky-crossposter/* .
RUN rm -rf bluesky-crossposter
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* \
           /tmp/* \
           /var/tmp/* \
           /usr/share/doc/* 

RUN mkdir -p input output local settings && \
    touch input/__init__.py output/__init__.py local/__init__.py settings/__init__.py && \
    for f in settings/*.txt ; do mv "$f" "${f%.txt}.py" ; done

RUN pip install --no-cache-dir -r requirements.txt

# Make sure run script is executable
RUN chmod +rxxx ./run.sh

CMD ["sh","./run.sh"]