
# create an oci container image with
# cd /home/expo && podman build -t expo:dev --rm -f troggle/Containerfile

# 
FROM docker.io/library/debian:bookworm

WORKDIR /home/expo2

RUN apt update && \
     apt install -y postgresql apache2 survex rsync git cgit proftpd \
     python3 python3-django python3-pil python3-piexif \
     python3-bs4 python3-unidecode python3-cryptography \
     libjs-codemirror

# do we need libjs-leaflet? libjs-sizzle? libjs-mgrs?

# Install non-packaged dependencies
# apt install CaveView and bins and libjs-proj4 from local repo/backports?
# Copy only the dependency files first
#wget troggle/pyproject.toml troggle/uv.lock
#RUN wget troggle/pyproject.toml && uv sync --frozen 

RUN useradd -m expo -G sudo -s /bin/bash

# Optional:install and configure BoE

#add apache config, enable modules
#configure postgres


#Start up services for apache, proftpd, postgresql, cron?

#end of system stage


# User files - separate layer?
RUN chown expo:expo .
USER expo

RUN mkdir -p repositories/git && cd repositories/git && \
    git clone http://expo.survex.com/repositories/troggle/.git && \
    git clone http://expo.survex.com/repositories/expoweb/.git && \
    git clone http://expo.survex.com/repositories/loser/.git && \
    git clone http://expo.survex.com/repositories/drawings/.git
RUN ln -s repositories/git/troggle troggle && \
    ln -s repositories/git/troggle expoweb && \
    ln -s repositories/git/troggle loser && \
    ln -s repositories/git/troggle drawings

RUN git config --global user.email "expo@potato.hut"
RUN git config --global user.name "expo"
RUN git config --global pull.rebase true

#rsync -az expo.survex.com:expofiles expofiles
#demo short version
#rsync -az expo.survex.com:expofiles/surveyscans/2018 expofiles/surveyscans/2018
#rsync -az expo.survex.com:expofiles/photos/2018/PhilipSargent/ expofiles/photos/2018/PhilipSargent

#/bin/sh is missing at this point - why?
RUN cd troggle && run databaseReset.py reset INIT

EXPOSE 8080
#Run postres process
CMD ["uv", "run", "python", "troggle/manage.py", "runserver", "0.0.0.0:8080"]
CMD ["bash"]

# move this file to the directory above troggle, loser etc before running the podman image build command.

# used image with:
# podman run -it  --network=host --rm expo:dev
