diff --git a/Containerfile b/Containerfile index d736ab6..f898443 100644 --- a/Containerfile +++ b/Containerfile @@ -9,14 +9,16 @@ RUN apt-get update && \ libboost-all-dev \ libeigen3-dev \ libtiff-dev \ + python3-venv \ + python3-pip \ make \ --no-install-recommends -WORKDIR /root - -ENV DISPLAY=:0 +COPY build.sh . RUN chmod +x build.sh && ./build.sh +ENV DISPLAY=:0 + CMD ["/bin/bash", "-c", "source /root/venv/bin/activate && qgis"] # CMD ["tail", "-f", "/dev/null"] diff --git a/README.md b/README.md index 9f7ade0..b7dca7d 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,37 @@ # QGIS container with Fire2A plugins -The container runs the latest version of QGIS with all of our tools without having to manually build and configure the -application on your system. The container is compatible with both Podman and Docker. We recommend using Podman, but the -instructions found here are easily translated into Docker. -### Everything that is not saved to the container directory `/mnt` will be lost once the container stops running. + +This container builds on top of the latest container version of QGIS with all of our tools built, installed and configured (see `Containerfile` and `build.sh` for details) +The container is compatible with both Podman and Docker. We recommend using Podman, but replacing podman with docker should work. +All you got to do is get the repos in the right place, build the container and run it! + +The right place is `qgis-vol` directory that'll be mounted on the Container. +- Remember that everything except files in this directory will be lost when the container is deleted/stopped, .e.g., temporary outputs of processing runs. +- A symbolic link to the `qgis-vol` directory will not work when running the container, so you have to copy the files into the directory (or move `build.sh` and `Container` properly). + ## TL;DR ```bash sudo apt install podman git + mkdir qgis-vol cd qgis-vol -git clone git@github.com:fire2a/qgis-pan-europeo.git + +git clone git@github.com:fire2a/C2F-W.git +git clone git@github.com:fire2a/fire-analytics-qgis-processing-toolbox-plugin.git toolbox git clone git@github.com:fire2a/fire2a-lib.git -git clone https://github.com/fire2a/fire-analytics-qgis-processing-toolbox-plugin.git toolbox -git clone https://github.com/fire2a/C2F-W.git -# build the container -podman build -t qgis-fire2a --volume $(pwd)/qgis-vol:/mnt -f Containerfile . -# run the container -podman run -it --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix:/tmp/.X11-unix --volume qgis-vol:/mnt --device /dev/dri --name fire2a qgis-fire2a -# be sure to save your qgis project in the mnt directory so you can access it later, otherwise it will be lost forever +git clone git@github.com:fire2a/qgis-pan-europeo.git + +# build the container "qgis-fire2a" image +podman build -t qgis-fire2a --volume $(pwd)/qgis-vol:/root -f Containerfile . + +# run the "fire2a" container +podman run -it --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix:/tmp/.X11-unix --volume qgis-vol:/root --device /dev/dri --name fire2a qgis-fire2a + +# enable our plugin on QGIS plugin manager. usually fails and needs a QGIS restart +# see https://fire2a.github.io/docs/qgis-management/plugins.html#dissapeared-plugin + +# restart the container +podman start qgis-fire2a ``` ## Prerequisites @@ -47,20 +61,20 @@ To build the container image using Podman, navigate to the directory where the c and run the following command: ```bash -podman build -t qgis-fire2a --volume Path/to/qgis-vol:/mnt -f Containerfile . +podman build -t qgis-fire2a --volume Path/to/qgis-vol:/root -f Containerfile . ``` This will build the container using a volume mount, sharing all that is in your local directory `qgis-vol` to the -directory `/mnt` in the container. +directory `/root` in the container. ## Run the container Once the image is built, you can run QGIS using Podman: ```bash -podman run -it --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix:/tmp/.X11-unix --volume ~/Path/to/qgis-vol:/mnt --device /dev/dri --name fire2a qgis-fire2a +podman run -it --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix:/tmp/.X11-unix --volume ~/Path/to/qgis-vol:/root --device /dev/dri --name qgis-fire2a qgis-fire2a ``` -You can use the QGIS application as you would normally. Everything you save onto the container directory `mnt` will +You can use the QGIS application as you would normally. Everything you save onto the container directory `root` will be saved to your local directory `qgis-vol`. **If you do not save your project to this directory, it will be lost when you close the application or the container**. @@ -68,4 +82,8 @@ To access the container's terminal while you're running QGIS, open another local ```bash podman exec -it qgis-fire2a bash ``` -### Remember that everything that is not saved to the container directory `/mnt` will be lost once the container stops running. + +To open the same container again do +```bash +podman start qgis-fire2a +``` diff --git a/build.sh b/build.sh index 07c2fc1..db3e749 100755 --- a/build.sh +++ b/build.sh @@ -1,20 +1,20 @@ #!/bin/env bash +set -x -cd C2F-W/Cell2Fire +cd ~/C2F-W/Cell2Fire make clean make -cd ../.. -python3 -m venv venv --system-site-packages -. venv/bin/activate -cd fire2a-lib +rm -fr ~/venv +python3 -m venv ~/venv --system-site-packages +. ~/venv/bin/activate +cd ~/fire2a-lib pip install -r requirements.build.txt pip install -r requirements.code.txt pip install -r requirements.txt pip install --editable . -cd .. -plugins_dir=~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ +plugins_dir=~/.local/share/QGIS/QGIS3/profiles/default/python/plugins mkdir -p $plugins_dir -ln -sf "$(pwd)/toolbox/fireanalyticstoolbox" "$plugins_dir/fireanalyticstoolbox" -ln -sf "$(pwd)/C2F-W" "$(pwd)/toolbox/fireanalyticstoolbox/simulator/C2F" +ln -sf ~/toolbox/fireanalyticstoolbox $plugins_dir/fireanalyticstoolbox +ln -sf ~/C2F-W ~/toolbox/fireanalyticstoolbox/simulator/C2F