Advertisement
Guest User

ntfy-docker-swarm

a guest
Jun 18th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.14 KB | None | 0 0
  1. version: "3.8"
  2.  
  3. ### VOLUMES
  4. ## I bind host folders to folders inside the container and therefore do not
  5. ## make use of docker volumes in this case. If you decide you want to do so
  6. ## though make sure you reference them here as well like so:
  7. #volumes:
  8. #ntfy-cache:
  9. #  driver: overlay
  10. #ntfy-userdb:
  11. #  driver: overlay
  12.  
  13. ### NETWORKS
  14. # Define the docker network. I personally use Traefik for all my reverse #
  15. # proxying on Docker Swarm.
  16. networks:
  17.   traefik-public:
  18.     external: true
  19.  
  20. ### SERVICES
  21. # Define the Ntfy-service. Note that the N is capitalized for a reason (it has # something to do with internal resolution of container names for those that
  22. # are curious)
  23.  
  24. services:
  25.   Ntfy:
  26.  # Name the service:
  27.     hostname: ntfy
  28.   # I host my own registry so it becomes:
  29.     image: registry.yourdomain.org/ntfy:armv7
  30.   # However you could easily replace that, like:
  31.     image: binwiederhier/ntfy:latest
  32.   # Configure networking and ports:
  33.     networks:
  34.       traefik-public:
  35.          aliases:
  36.           - ntfy
  37.   # Expose port 80 and 443 inside the container to 8008 and 4433 on the host
  38.     ports:
  39.       - target: 80
  40.         published: 8008
  41.         protocol: tcp
  42.         mode: host
  43.       - target: 443
  44.         published: 4433
  45.         protocol: tcp
  46.         mode: host
  47.    # Run the serve command once the container is up
  48.     command:
  49.      - serve
  50.   # Mount some volumes for persistency. Note that while I use bindmounts to
  51.   # directories on the host filesystem here, you are perfectly fine with
  52.   # docker volumes as well
  53.     volumes:
  54.      - /mnt/docker/ntfy/cache:/var/cache/ntfy:rw
  55.       - /mnt/docker/ntfy/lib:/var/lib/ntfy:rw
  56.       - /mnt/docker/ntfy/etc:/etc/ntfy:rw
  57.       - /mnt/docker/ntfy/etc/server.yml:/etc/ntfy/server.yml:ro
  58.     deploy:
  59.    # Deploy a single instance of the container
  60.       mode: replicated
  61.       replicas: 1
  62.     # Decide where the container is placed by using docker labels.
  63.     # I want it to be on one of my raspberry nodes so I use this:
  64.       placement:
  65.        # preferences:
  66.         #   - spread: node.labels.type == worker
  67.         constraints:
  68.          - node.labels.type == raspberry
  69.     # Configure how the service should behave when updating
  70.       update_config:
  71.         parallelism: 1
  72.         delay: 5s
  73.         order: stop-first
  74.     # Define the amount of system resources that the service can use
  75.       resources:
  76.         limits:
  77.           cpus: '0.30'
  78.           memory: 124
  79.       reservations:
  80.         cpus: '0.05'
  81.         memory: 24M
  82.     # Define the runtime labels (for example to instruct Traefik)
  83.       labels:
  84.        - 'traefik.enable=true'
  85.         - 'traefik.docker.network=traefik-public'
  86.         - 'traefik.constraint-label=traefik-public'
  87.         - 'traefik.http.routers.ntfy.rule=Host(\`ntfy.yourdomain.org\`)'
  88.         - 'traefik.http.routers.ntfy.service=ntfy@docker'
  89.         -  'traefik.http.routers.ntfy.entrypoints=https'
  90.         - 'traefik.http.routers.ntfy.tls=true'
  91.         - 'traefik.http.routers.ntfy.tls.certresolver=cloudflare'
  92.         - 'traefik.http.routers.ntfy.middlewares=authelia@docker'
  93.         - 'traefik.http.services.ntfy.loadbalancer.server.port=80'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement