Sha256: 75447cac824ed2043f77796786805865e7364f816dd1eb31482ba5a3fed4b79a

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

version: "3"
<%
https = upstreams.any?{|upstream| upstream[:domains].any?{|domain| domain.include?("https://")}}
to_yaml = proc do |struct|
  struct.to_h.inject({}){|h, (k, v)| h[k.to_s] = v; h}.to_yaml
end
%>
services:

  nginx:
    image: nginx:1.15-alpine
    container_name: nginx
    restart: unless-stopped
    ports:
      - 80:80
      <%- if https %>
      - 443:443
      <%- end %>
    depends_on:
      <%- upstreams.each do |upstream| %>
      - <%= upstream.name %>
      <%- end %>
    volumes:
      - ./data/nginx:/etc/nginx/conf.d
  <%- if https %>
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

  certbot:
    image: certbot/certbot
    container_name: certbot
    restart: unless-stopped
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
  <%- end %>
  <%- upstreams.each do |upstream| %>

  <%= upstream.name %>:
    image: <%= upstream.name %>
    restart: always
    <%- unless upstream[:compose].inspect.match(/\bports\b/) %>
    ports:
      - <%= upstream.port %>
    <%- end %>
    <%- if upstream[:compose] %>
<%= to_yaml.(upstream[:compose]).sub(/^.*?\n/, "").indent(4) %>
    <%- end %>
  <%- end %>
  <%- services.each do |service, config| %>

  <%= service %>:
<%= to_yaml.(config).sub(/^.*?\n/, "").indent(4) %>
  <%- end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vps-0.1.1 templates/docker/docker-compose.yml.erb