sablierapp / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://sablierapp.dev/
GNU Affero General Public License v3.0
1.36k stars 46 forks source link

Add options to not use reverse proxy integration #247

Closed juldum54 closed 9 months ago

juldum54 commented 9 months ago

Hi ! First of all, thanks for this great project :)

I would like to use the Sablier container in a Docker compose project without the reverse proxy integration. For some reasons, I cannot use a reverse proxy, and still need a way to automatically start/stop containers based on their usage/ongoing requests, as the sablier plugin provides.

I don't know if sablier can be used without a reverse proxy as the documentation does not really provide any example without one, so maybe this issue is just related to updating the doc.

If that's not the case, here's another project to automatically start/stop containers based on network activity. The Lazytainer project is great but is not well maintained nor provides a "waiting page" while services are starting.

The idea here would be to create a sablier service within the Docker compose projet and use additional parameters (e.g. the targeted port of a given service). The sablier service would handle requests in front of the targeted service, display the loading page if the container is not started, and then forward requests to it when it's ready, without relying on reverse proxy integration to do so.

Is it something currently achievable or is it considered as a new feature ? Thanks !

acouvreur commented 9 months ago

I believe you'd like Sablier to have native reverse proxy capabilities, right ? So that Sablier has built it routing and lazy loading of services.

Can you provide me with a sample of integration on how you'd see this setup in the first place ?

I'd recommend on using a dedicated reverse proxy for these tasks, but it can be quite a challenge learning one sometime.

juldum54 commented 9 months ago

Thanks for your response. After further reading, I can in fact customize the nginx config of Synology WebStation.

I'll close this issue as this is just some additional config and reading to do on my end, sorry for bothering!

Here's my original response for context:


I'll briefly explain my setup and why I may not need the reverse proxy integration.

TLDR; the reverse proxy I use now cannot be customised for Sablier to work. Either :

I have a Synology NAS on my private home network. Additional services/apps are exposed as Docker compose projects, and are reverse proxied with the Nginx installed on the NAS (WebStation), but this is not very customizable (some Nginx options are not present and I can't install modules). Everything works fine, but I need to stop unused services to save RAM and CPU on the NAS. Here comes the Sablier part.

The way Lazytainer works is quite simple : you add a lazytainer service in your Docker compose project, expose its ports, set its config to match the targeted port of your targeted service to manager, and voilà! Here's a working example:

version: "3.8"

services:

  whoami:
    image: "traefik/whoami"
    depends_on:
      - lazytainer
    labels:
     - "lazytainer.group=whoami"
    network_mode: service:lazytainer

  lazytainer:
   image: ghcr.io/vmorganp/lazytainer:master
   container_name: lazytainer
   ports:
     - "8080:80"
   volumes:
     - /volume1/docker/docker.sock:/var/run/docker.sock:ro
   labels:
     - "lazytainer.group.whoami.ports=80" # whoami container is accessible on port 80.
     - "lazytainer.group.whoami.pollRate=5" # Just to speed up the waking process.
     - "lazytainer.group.whoami.inactiveTimeout=5" # Just to speed up the waking process.
     - "lazytainer.group.whoami.minPacketThreshold=1" # Just to speed up the waking process.
   environment:
     - VERBOSE=true # Log everything.

After 30 seconds of inactivity, the whoami container will be stopped. Then, if you try to access http://whatever:8080, the lazytainer will see the request and try to wake up the whoami container. Then, reload your page: the whaomi container is now accessible. This is quite similar to Sablier accomplishes with the reverse-proxy integration (with labels). Here, it's done by hooking the network namespace of the whoami service into the lazytainer one (network_mode: service:lazytainer).

I could use Traefik as a reverse proxy (I used it before switching to the Synology provided one), but the only problem here is that it's not as comfy and need additional setup on my end.