Sha256: 0dc0e3c39ea9e42e455a7b134fcb1f2972e3224605d153623664c94052376590

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

version: "3"
<% https = upstreams.any?{|upstream| upstream[:domains].any?{|domain| domain.include?("https://")}} %>
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:v0.27.1
    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 %>
  <%- services.to_h.each do |name, spec| %>

  <%= name %>:
<%= OpenStruct.to_hash(spec).to_yaml.sub(/^.*?\n/, "").indent(4) %>
  <%- 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] %>
<%= OpenStruct.to_hash(upstream[:compose]).to_yaml.sub(/^.*?\n/, "").indent(4) %>
    <%- end %>
  <%- end %>
<%- unless (volumes || []).empty? %>

volumes:
<%- volumes.each do |volume| %>
  <%= volume %>:
<%- end %>
<%- end %>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vps-0.2.1 templates/docker/docker-compose.yml.erb
vps-0.2.0 templates/docker/docker-compose.yml.erb
vps-0.1.2 templates/docker/docker-compose.yml.erb