Skip to content

Instantly share code, notes, and snippets.

@ShahinSorkh
Created February 15, 2021 07:46
Show Gist options
  • Save ShahinSorkh/9322c34bc09ebef03156eac45c8f1d76 to your computer and use it in GitHub Desktop.
Save ShahinSorkh/9322c34bc09ebef03156eac45c8f1d76 to your computer and use it in GitHub Desktop.
run adminer:fastcgi using docker-compose
#!/bin/sh
cat <<EOF >/tmp/adminer.conf
server {
listen 80;
server_name localhost;
index index.php;
location ~ ^/(index.php)?$ {
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/index.php;
fastcgi_param DOCUMENT_ROOT /var/www/html/;
fastcgi_pass adminer:9000;
}
}
EOF
cat <<EOF >/tmp/adminer.yaml
version: '3.7'
services:
adminer:
image: adminer:fastcgi
nginx:
image: nginx:alpine
ports:
- 8080:80
volumes:
- /tmp/adminer.conf:/etc/nginx/conf.d/default.conf:ro
EOF
docker-compose -f /tmp/adminer.yaml $*
@ulexxander
Copy link

Works like a charm, thanks!

Adopted it for Kubernetes:

apiVersion: v1
kind: Service
metadata:
  name: adminer
  labels:
    app.kubernetes.io/name: adminer
spec:
  selector:
    app.kubernetes.io/name: adminer
  ports:
    - name: nginx-frontend
      port: 80
      targetPort: nginx-frontend

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: adminer
spec:
  ingressClassName: your-ingress-class
  tls:
    - hosts:
        - "*.your.host"
  rules:
    - host: adminer.your.host
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: adminer
                port:
                  name: nginx-frontend

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: adminer-nginx
  labels:
    app.kubernetes.io/name: adminer
data:
  default.conf: |
    server {
        listen       80;
        server_name  localhost;
        index index.php;
        location ~ ^/(index.php)?$ {
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME /var/www/html/index.php;
            fastcgi_param  DOCUMENT_ROOT   /var/www/html/;
            fastcgi_pass localhost:9000;
        }
    }

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: adminer
  labels:
    app.kubernetes.io/name: adminer
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: adminer
  template:
    metadata:
      labels:
        app.kubernetes.io/name: adminer
    spec:
      containers:
        - name: adminer
          image: adminer:4.8.1-fastcgi
          imagePullPolicy: IfNotPresent
          ports:
            - name: adminer-fastcgi
              containerPort: 9000
          resources:
            requests:
              cpu: 20m
              memory: 128Mi
            limits:
              memory: 1024Mi
        - name: nginx
          image: nginx:1.27.2-alpine
          imagePullPolicy: IfNotPresent
          ports:
            - name: nginx-frontend
              containerPort: 80
          volumeMounts:
            - name: adminer-nginx
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
          resources:
            requests:
              cpu: 20m
              memory: 64Mi
            limits:
              memory: 64Mi
      volumes:
        - name: adminer-nginx
          configMap:
            name: adminer-nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment