Skip to content

Docker Compose

For getting the most performance out of PutFS, use bare metal deployment via systemd instead.

Basic setup

The inlined config is the minimal working example for nginx that routes the incoming requests properly to nginx itself (GET / HEAD) and PutFS api (PUT, DELETE, as well as the GET listings via the trailing slash paths).

See the References section for various nginx config examples for different scenarios.

Keys are defined in ./keys/keys.conf. See Auth for the key file format and scoping.

services:
  api:
    image: ghcr.io/dataresearchcenter/putfs
    environment:
      PUTFS_ROOT: /data
    volumes:
      - ./data:/data
      - putfs_run:/run/putfs

  nginx:
    image: nginx:alpine
    depends_on:
      - api
    ports:
      - 8000:80
    volumes:
      - ./data:/data:ro
      - ./keys:/keys:ro
      - putfs_run:/run/putfs:ro
    configs:
      - source: nginx_conf
        target: /etc/nginx/nginx.conf

configs:
  nginx_conf:
    content: |
      worker_processes auto;
      events {}
      http {
        include mime.types;
        default_type application/octet-stream;
        sendfile on;
        access_log off;

        upstream api {
          server unix:/run/putfs/putfs.sock;
        }

        include /keys/keys.conf;

        server {
          listen 80;

          if ($$key_ok != "1") { return 401; }
          if ($$auth_ok != "1") { return 403; }

          location ~ /$ {
            proxy_pass http://api$$uri$$is_args$$args;
          }

          location / {
            limit_except GET HEAD {
              proxy_pass http://api;
            }
            root /data;
            try_files $$uri =404;
          }
        }
      }

volumes:
  putfs_run: