virtuoso-opensource icon indicating copy to clipboard operation
virtuoso-opensource copied to clipboard

Running Virtuoso as a service in GitLab CI

Open claudiu-cristea opened this issue 1 year ago • 3 comments

I have a case where I need to run VOS as a service in a GitLab CI (here's the gitlab-ci.yml file). In order to run the tests against the Virtuoso service, I need to set some permissions with isql:

DB.DBA.RDF_DEFAULT_USER_PERMS_SET('SPARQL', 7, 0);
GRANT SPARQL_UPDATE TO "SPARQL";

No idea how to run these commands because, with GitLab CI, I cannot map an .sql file inside the container, so that it would run as part of initdb.d.

Does anyone have a suggestion or clue?

claudiu-cristea avatar Feb 21 '24 16:02 claudiu-cristea

Any chance for a feature that would allow to set permissions via env variables passed to the container, in a similar way as VIRT_* vars? That would allow to set permissions without needing to mount initdb.d in cases such GitLab CI, where we cannot do it.

The unofficial image https://hub.docker.com/r/tenforce/virtuoso is doing that but only for SPARQL_UPDATE

claudiu-cristea avatar Feb 22 '24 07:02 claudiu-cristea

The Virtuoso docker containers do not have support for the SPARQL_UPDATE environment variable, and there are no plans to implement such. Also, they only run one of the two commands you are seeking to run, so you need a more generic method.

The gitlab-ci.yml file you provided seems to have changed and now references the tenforce virtuoso docker image? In the original I saw, you were using the command attribute to make isql connect and run the required commands, which didn't look correct as it appeared to have mismatched double and single quotes, but now it has disappeared and so I cannot comment on why it was not working. But — something like the following should work:

command: ["/opt/virtuoso-opensource/bin/isql", "1111", "dba", "xxx", "EXEC=SELECT 'Hello World'"]

If you want to run custom commands on startup with the initdb.d scripts method, with something like GitLab CI which cannot map an .sql file inside the container, you can create your own own custom Virtuoso container with the docker FROM {image-name} command, and add the Virtuoso commands you want to run when starting your custom image to the initdb.d scripts of your own container image, which GitLab CI can then reference.

HughWilliams avatar Feb 22 '24 13:02 HughWilliams

The Virtuoso docker containers do not have support the SPARQL_UPDATE environment variable and there are no plans to implement such. Also, they only run one of the two commands you are seeking to run, so you need a more generic method.

Yes, I understand this. I was thinking that this could be a future improvement: To allow setting various permissions via container environment vars. It would help with cases such as GitLab CI, where it's not possible to share a volume between host and container.

The gitlab-ci.yml file you provided seems to have changed and now references the tenforce virtuoso docker image? In the original I saw, you were using the command attribute to make isql connect and run the required commands, which didn't look correct as it appeared to have mismatched double and single quotes, but now it has disappeared and so I cannot comment on why it was not working.

The point is that, in my case, I need a triplestore in tests. I have to test whether some triples are correctly inserted/updated/deleted (including graph store operations) in a triplestore. I've tried with Virtuoso official image, then with Fuseki (not familiar at all with F), and, finally, I went with tenforce virtuoso docker image, just to not spend much time as that allows setting the SPARQL_UPDATE permission via env vars and has the other permissions set by default. Not a long term solution; I'll try to switch to Virtuoso official image when I have time to experiment with the "EXEC=SELECT 'Hello World'" command

But — something like the following should work:

command: ["/opt/virtuoso-opensource/bin/isql", "1111", "dba", "xxx", "EXEC=SELECT 'Hello World'"]

It's hard to understand how to escape quotes in the above, as double quotes are also present in the commands being executed.

If you want to run custom commands on startup with the initdb.d scripts method, with something like GitLab CI which cannot map an .sql file inside the container, you can create your own custom Virtuoso container with the docker FROM {image-name} command, and add the Virtuoso commands you want to run when starting your custom image to the initdb.d scripts of your own container image, which GitLab CI can then reference.

I know that this would work but it's quite a complicated for the simple tasks that I have to do.

claudiu-cristea avatar Feb 28 '24 12:02 claudiu-cristea