gitlist icon indicating copy to clipboard operation
gitlist copied to clipboard

Docker volume mounts aren't explored??

Open bmagistro opened this issue 3 years ago • 8 comments

I'm trying to run v2.0.0 in a docker container mounting in a path to the various git repos but it does not seem to be explored. If I use a local directory, it is traversed and the repos are found. Unfortunately I cannot run gitlist locally/natively easily due to dependencies/conflicts which is why I'm trying to utilize a container with a volume mount. I can confirm that the www-data user can access the files in the mount point (su -s /bin/bash www-data; ls /repos). I did quickly spin up v1.1.1 and it can access the repos via the mount point.

Happy to contribute a complete dockerfile + configs back if I can sort this out.

FROM php:8.1.1-apache-bullseye

RUN apt-get update \
 && apt-get --yes --no-install-recommends install git unzip \
 && apt-get clean \
 && mkdir /var/www/gitlist \
 && cd /var/www/gitlist \
 && curl -L https://github.com/klaussilveira/gitlist/releases/download/2.0.0/gitlist-2.0.0.zip -o gitlist.zip \
 && unzip gitlist.zip \
 && rm gitlist.zip \
 && mkdir cache \
 && chown -R www-data:www-data /var/www/gitlist \
 && a2enmod rewrite

COPY apache-gitlist.conf /etc/apache2/sites-enabled/000-default.conf

WORKDIR /var/www/gitlist

ENV DEFAULT_REPOSITORY_DIR=/repos

EXPOSE 80/tcp

VOLUME /repos

The edit in sites-enabled is to update the docroot to ..../public.

bmagistro avatar Jan 16 '22 02:01 bmagistro

Environment variables have to be set using SetEnv inside your VirtualHost:

https://httpd.apache.org/docs/current/mod/mod_env.html#setenv

Apache does not expose the system environment variables to sub-processes.

klaussilveira avatar Jan 17 '22 22:01 klaussilveira

I'm not convinced this is/the only issue, but can explore it further. I've also tried setting default_repository_dir and it still wasn't populating, looks like I forgot to mention this.

Edit: Adding SetEnv DEFAULT_REPOSITORY_DIR=/repos does not appear to make any difference.

bmagistro avatar Jan 17 '22 22:01 bmagistro

Ping

I'm open to other ideas. Ignoring the env issue, even setting the config file to the path directly did not work. Short of doing this as a developer build (haven't done much with php in a few years) are there any debug flags/logs that can be enabled to help track this down?

bmagistro avatar Feb 08 '22 19:02 bmagistro

Environment variables have to be set using SetEnv inside your VirtualHost:

https://httpd.apache.org/docs/current/mod/mod_env.html#setenv

Apache does not expose the system environment variables to sub-processes.

I think I have the same issue, the webpage works but I can't see any repositories. I've configured my repository via config.yml

repositories: - /srv/git/tst/test1.git

Which variable should I set via SetEnv?
gitlist version 2.0.0 php 8.1.3 git 2.30.2

Gusiph avatar Feb 27 '22 17:02 Gusiph

@bmagistro Did you figure this out yet?

It sure looks like there is a lot in the example docker/nginx/nginx.conf config that isn't going to work the same as a Apache config. I haven't figured out everything you need to translate that to Apache. Also, there doesn't seem to be an Apache config for v2.0.0 anywhere that I have found.

zoredache avatar Apr 11 '22 23:04 zoredache

I have not yet. I will double check the config I had and see what translates. We use both so if it is that simple I should be able to crack it in the next few days if I get some time.

bmagistro avatar Apr 12 '22 02:04 bmagistro

@bmagistro been playing around with this a bit more. Adding something like this to your image might get you most of the way there.

Dockerfile

...
ADD apache_gitlist.conf /etc/apache2/conf-enabled/gitlist.conf

apache_gitlist.conf

<Location />
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]
</Location>

zoredache avatar Apr 12 '22 07:04 zoredache

This make no difference. It also appears that mod_rewrite may not be in use as there is 1) no .htaccess file anymore and 2) no mention of it in the current install documentation. There is mention of it in the older troubleshooting section (~2y +? from v2.0.0).

As mentioned before, apache can read the volume mount (aliased and exposed) but the php process (not fpm, mod_php -- https://hub.docker.com/_/php) doesn't seem to be able to and I don't seem to get any errors in the logs (yes its turned up to E_ALL). I am opting away from a multi container setup here, I can try to setup the fpm + nginx containers referenced in the repo and see if the behavior is different...

bmagistro avatar Apr 12 '22 13:04 bmagistro