Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistency in the configure() procedure #56

Open
MaxiReglisse opened this issue Sep 11, 2023 · 5 comments
Open

inconsistency in the configure() procedure #56

MaxiReglisse opened this issue Sep 11, 2023 · 5 comments

Comments

@MaxiReglisse
Copy link

There's a problem with variable assignment and use of the same variable in the configure() procedure.

source $INSTALL_SOURCE/env.default

docker run -it \
    -u $LIZMAP_UID:$LIZMAP_GID \
    --rm \
    -e INSTALL_SOURCE=/install \
    -e INSTALL_DEST=/lizmap \
    -e LIZMAP_DIR=$INSTALL_DEST \
    -e QGSRV_SERVER_PLUGINPATH=/lizmap/plugins \
    -v $INSTALL_SOURCE:/install \
    -v $INSTALL_DEST:/lizmap \
    -v $scriptdir:/src \
    --entrypoint /src/configure.sh \
    3liz/qgis-map-server:${QGIS_VERSION_TAG} _configure

Indeed, if you add the following lines to the env.default file:

INSTALL_SOURCE=/home/docker/lizmap-docker-compose
INSTALL_DEST=/home/docker/lizmap

And then you run the Docker command without modification, it can potentially create a conflict because you have defined INSTALL_SOURCE in both env.default and in the Docker command options. This could lead to unexpected issues as Docker will take the value specified in the Docker command options (in this case, /install) rather than the one defined in env.default.

what do you think of it?

Thanks in advance,

Ernest.

@MaxiReglisse
Copy link
Author

It's possible that I really don't understand what you're doing and I hope you'll forgive me.

But i have the impression that you're mixing host environment variables with those of the installation container. In my opinion, you can't call host variables when you're in the installation container.

For example, the only copy command the container can understand is this one:

cp /install/env.default /lizmap/.env

not that one:

cp $INSTALL_SOURCE/env.default $INSTALL_DEST/.env

It's because you've shared the folders between the host and the installation container that this command with fixed paths works correctly.

    docker run -it \
        -u $LIZMAP_UID:$LIZMAP_GID \
        --rm \
        -e QGSRV_SERVER_PLUGINPATH=/lizmap/plugins \
        -v $INSTALL_SOURCE:/install \
        -v $INSTALL_DEST:/lizmap \
        -v $scriptdir:/src \
        --entrypoint /src/configure.sh \
        3liz/qgis-map-server:${QGIS_VERSION_TAG} _configure

By applying this principle to the entire configure.sh script, I manage to install lizmap data in both /docker/lizmap and /home/docker/lizmap.

But I've come across an error that has nothing to do with it, or so I assume.

invalid query ERROR:  relation "jlx_user" does not exist

Thank you in advance for your feedback.

Ernest.

@MaxiReglisse
Copy link
Author

Yesterday I suggested using the following command to copy the file /install/env.default to /lizmap/.env, but this is impossible as it stands because of the rights that are set in the container.

For proof of this, simply launch the container in detached mode (-d) and use the command "tail -f /dev/null" to keep it running by monitoring the fictitious file /dev/null, which prevents the container from terminating.

docker run -itd \
        -u 1001:1001 \
        -e QGSRV_SERVER_PLUGINPATH=/lizmap/plugins \
        -v /home/docker/lizmap-docker-compose:/install \
        -v /home/docker/lizmap:/lizmap \
        -v /home/docker/lizmap-docker-compose:/src \
        --entrypoint /src/configure.sh \
        3liz/qgis-map-server:3.30.1-1.8.8 \
        tail -f /dev/null

You can then log in and see that /install is owned by LIZMAP_UID:LIZMAP_GID (1001:1001 in my case), while the destination folder, /lizmap, is owned by root:root.

$ docker exec -it inspiring_bassi bash
I have no name!@4c8d992c3402:/$ ls -l /
total 84
...
-rwxr-xr-x   1 root root 3713 Apr  7 11:13 docker-entrypoint.sh
...
drwxr-xr-x   7 1001 1001 4096 Sep 12 13:18 install
...
drwxr-xr-x   2 root root 4096 Sep 12 11:48 lizmap

The command cp /install/env.default /lizmap/.env will fail... unless you modify the docker-entrypoint.sh entry point, but I'm afraid that would take us too far.

Thank you in advance for your feedback.

Ernest.

@dmarteau
Copy link
Member

The installation process requires that some operations are done in a container (plugins installation), this is why some paths need to be relative to paths mounted in the container.

while the destination folder, /lizmap, is owned by root:root.

The configure scripts does not allow for root installation on purpose: too many peoples shoot themselve in the foot because of that.

The lizmap docker compose is mainly a test configuration for people that want a quick running install.
and the basic command ./configure.sh configure do the job in installing a default lizmap configuration in the local folder.

If you need a more custom installation in a specific location you cannot rely on the ./configure script as is, you'll problably need to copy the files install config elsewhere and override the configure.sh scripts to fit your custom target directory:

Something like that should work:

#!/bin/sh

#
# Run the lizmap deployment from the current config
#

export \
LIZMAP_UID=$(id -u <user>) \
LIZMAP_GID=$(id -g <user>) \
INSTALL_DEST=/my/destination/location \
INSTALL_SOURCE=$(pwd)
LIZMAP_CUSTOM_ENV=1

# Customize your environment
envsubst < env.default.in > env.default

# Call the original configure script
../lizmap-docker-compose/configure.sh configure

@MaxiReglisse
Copy link
Author

Thank you for your feedback but alas I was unable to carry out the desired installation with your advice. So I had to make do with a standard configuration and a manual data move.
An important prerequisite is to share the lizmap database data between the host and the container, with the following modification to docker-compose.yml.

volumes:
  # - { type: volume, source: postgis_data, target: /var/lib/postgresql/data }
  - ${LIZMAP_DIR}/var/lizmap-db:/var/lib/postgresql/data

I took the opportunity to choose the most recent versions of the basic applications.

LIZMAP_VERSION_TAG=${LIZMAP_VERSION_TAG:-"3.6.5"}
QGIS_VERSION_TAG=${QGIS_VERSION_TAG:-"3.30.1-1.8.8"}
POSTGIS_VERSION=${POSTGIS_VERSION:-"15-3"}

First, I run the configuration tool :

./configure configure

Then I launch the docker composition.

docker compose up -d

I stop docker composition by using a command that destroys all non-permanent volumes.

docker rm -f $(docker ps -a -q) && docker volume rm $(docker volume ls -q) && docker network rm $(docker network ls -q)

With the root user, I moved the data into the target directory (outside the docker composition download folder because it's supervised by git!).

# mv /home/docker/lizmap-docker-compose/lizmap /docker/.
# chown -R docker:docker /docker/

Finally, you just need to point the .env symbolic link to the destination folder and correct its contents.

ln -s /docker/lizmap/.env .env

cat .env
LIZMAP_PROJECTS=/docker/lizmap/instances
LIZMAP_DIR=/docker/lizmap
...

You can then restart the Docker composition and check that the data between the host and the containers is shared, thus guaranteeing data continuity.

All this in a non-git-ed folder!

Ernest.

@Gustry
Copy link
Member

Gustry commented Sep 17, 2024

Is this issue still relevant ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants