TimWolla / docker-adminer

Database management in a single PHP file
https://hub.docker.com/_/adminer/
157 stars 69 forks source link

How to properly connect css in fastcgi mode? #91

Closed yareg-com closed 3 years ago

yareg-com commented 3 years ago

I use adminer:fastcgi with caddy, both in docker containers and can't figure out how to properly connect adminer.css. The only way I managed to get it working is via volume but in that case the contents of the volume is not updated automatically when the adminer container is upgraded. What is the best practice to achieve this?

Here's my Caddyfile snippet:

redir /adminer /adminer/

route /adminer/* {
    uri strip_prefix /adminer

    php_fastcgi adminer:9000 {
        root /var/www/html
    }
}

Trying to solve the problem using volume I did like this:

Caddyfile:

redir /adminer /adminer/

  route /adminer/* {
      uri strip_prefix /adminer
      root * /adminer

      file_server @static

      php_fastcgi adminer:9000 {
          root /var/www/html
      }
  }

docker-compose.yml:

volumes:

  adminer:

services:

  caddy:
    image: caddy:2.3.0
...
    volumes:
      - adminer:/adminer:ro

 adminer:
    image: adminer:fastcgi
...
    volumes:
      - adminer:/var/www/html

Thanks in advance!

TimWolla commented 3 years ago

I use adminer:fastcgi with caddy, both in docker containers and can't figure out how to properly connect adminer.css.

Route the request to adminer.css to the index.php in the container. The script specifically contains logic to serve the adminer.css if the index.php is executed while the address bar says adminer.css:

https://github.com/TimWolla/docker-adminer/blob/e49bfb0b9bfa018fb7347212258d56cb13be9ecb/4/fastcgi/index.php#L32-L36

For nginx I use the following config:

    location ~ ^/adminer(/.*$|$) {
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/html/index.php; # Hardcoded index.php here
        fastcgi_pass adminer:9000;
    }